The goal is to have Visual Basic script refreshing the external data of an xlsm file.
The script runs without errors, but afterwards, nothing has happened to the xlsm file. It seems like the script continuous before all the data has been refreshed.
I've tried a few things already.
- Disabling background query update
- Application.CalculateUntilAsyncQueriesDone
- WScript.Sleep ... to force the script to wait until refresh is finished, at the moment I'm trying with 30 minutes, shouldn't need more than 15 minutes though
Here is the script's content:
Option Explicit
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("name_of_my_file.xlsm")
xlBook.RefreshAll
WScript.Sleep 1800000
xlBook.Save
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
WScript.Echo "Finished test v2, i.e. refreshing data"
WScript.Quit