I am using Microsoft Excel to pull from a database using the ODBC connection. When changes are made to the database, we sometimes have to reselect the data source when we try to run a refresh in excel. Currently, I macro'd excel file is opened by task scheduler every morning that refreshes and saves several query-linked excel files. Recently a change was made to the database, and now the task scheduler won't run correctly because when it opens the macro'd excel file, the odbc drive prompt appears.
Is there a way to code a data source selection into the macro? My current macro looks like this:
Is there a way to code a data source selection into the macro? My current macro looks like this:
Code:
Sub DailyApplications()
'
' DailyApplications Macro
' Macro recorded 8/26/2005 by J
'
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveWorkbook.Save
Workbooks.Open Filename:= _
"S:\IS\REPORTS, LAYOUT CRITERIA & TOTALS\SQL Queries\MPD- SQL\Daily applications\Emp_St_Dt.xls"
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
Workbooks.Open Filename:= _
"S:\IS\REPORTS, LAYOUT CRITERIA & TOTALS\SQL Queries\MPD- SQL\Daily applications\Open_Dt.xls"
Selection.QueryTable.Refresh BackgroundQuery:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.Quit
End Sub