In the below open file.xlsx, let the odbc query execute, save, and close. The code does execute but there will always only be one file.xlsx and a loop is currently running on a directory, that I can not seem to fix. The other issue is the wscript.sleep(20000) because what if the query needs longer, I can't seem to set that to not be a fixed time, rather let the query execute, save and close. Thank you :)
VB
VB
Code:
Set fso = CreateObject("Scripting.FileSystemObject")
Set xl = CreateObject("Excel.Application")
xl.Visible = True
For Each f In fso.GetFolder("C:\path").Files
If LCase(fso.GetExtensionName(f.Name)) = "xlsx" Then
Set wb = xl.Workbooks.Open(f.Path)
wb.RefreshAll
wscript.sleep(20000)
wb.Save
wb.Close
End If
Next
xl.Quit