I have put together a VB script to refresh all excel files in a folder without opening them. The issue I am facing is that the excel files close before allowing the data to be refreshed. Is there any way to force the VB Script to wait till the data is refreshing and then save the file? Also, I am not sure what each file takes to refresh.
The query is as follows:
Set fs = CreateObject("Scripting.FileSystemObject")
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = False
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Excel") > 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.path)
oWorkbook.RefreshAll
oWorkbook.Save
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
Set oExcel = Nothing
Any help will be highly appreciated.
Thanks
The query is as follows:
Set fs = CreateObject("Scripting.FileSystemObject")
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = False
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Excel") > 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.path)
oWorkbook.RefreshAll
oWorkbook.Save
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
Set oExcel = Nothing
Any help will be highly appreciated.
Thanks