admin管理员组

文章数量:1123049

I have a VBA macro to refresh all data connections in the excel file. This runs fine with no errors. When I run the script below through task scheduler the status gets stuck at running and does not end. Why is it getting stuck/not completing?

Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")

xlApp.DisplayAlerts = False

Set xlBook = xlApp.Workbooks.Open("Z:\FileToRefresh.xlsm", , False)

xlApp.Run "RefreshData"

Do While xlApp.CalculationState <> 0
    DoEvents
Loop

xlBook.Save
xlBook.Close
xlApp.Quit

Set xlBook = Nothing
Set xlApp = Nothing

本文标签: vbscriptTask Scheduler Excel refresh stuck on runningStack Overflow