Hi All,

I am new(er) to VBA, and am requesting your help! I have one master excel file (a library of other excel files if you will), and I want to be able to open another excel file from the master file. The file I want to open, will refresh the query data connections, then save and close it at specified time interval. My question is, how can I do this on a 12 hour time interval and get it to loop back to the beginning and complete this process all over again? I want to do this with several files, that is why I have one master file which houses macros to do the same with other files. This is what I have for code so far:

Sub auto_open()

Call ScheduleDataRefresh

End Sub
Sub ScheduleDataRefresh()

TimeToRun = Now + TimeValue("12:00:00")
Application.OnTime TimeToRun, "Refresh"

End Sub
Sub Refresh()

' This subroutine refreshes the data connections for the (3)
' queries in this campaign dashboard.

Workbooks.Open Filename:="H:\Data.xlsx"
ActiveWorkbook.Connections("Query from abc").Refresh
ActiveWorkbook.Connections("Query from 123").Refresh
ActiveWorkbook.Connections("Query from xyz").Refresh
ActiveWorkbook.Save
ActiveWorkbook.Close False

End Sub
Sub auto_close()

Application.OnTime TimeToRun, "Refresh", , True

End Sub

Also tried this with Task Scheduler, but did not have much luck. Basically this needs to refresh data connections at 6 am and 6 pm so we can use the data during the day.

Thanks for any help,
jtukes