Fix Power Query Loading During a Scheduled Excel Refresh
Question details
A user needs a scheduled Excel macro to wait until Power Query is ready before starting a refresh.

- Product
- Microsoft Excel Power Query
- Device & OS
- Windows
- Scenario
- Windows Task Scheduler launches Excel and a macro that refreshes Power Query data.
- Observed behavior
- The macro fails when it starts, but completes after the user selects Debug and then Run.
Check the task's action and account in Windows Task Scheduler, and confirm that the workbook and its data sources are accessible under that account. Open the workbook manually in Excel and verify that the query refreshes from the Data tab.
Control Excel startup and retry transient refresh failures
Use this approach when the scheduled macro appears to run before Excel or the required query components are ready.
The original issue was reported as resolved without a specific fix. The steps below are troubleshooting guidance for similar timing-related failures.
A fixed delay alone cannot confirm that Power Query is ready. A bounded retry can help with a temporary startup failure, but it should not repeat operations that would create duplicate data or other unintended changes.
Open Task Scheduler, select the task, and choose Properties > Actions. Check how Excel and the workbook or automation script are launched, and identify where the refresh macro starts.
In Excel, press Alt+F11 and inspect the workbook's startup code or the macro called by the automation script. Arrange for the refresh routine to run only after the workbook is open and the required components have had time to initialize.
In the VBA editor, add error handling around the refresh operation to record the error and retry only a limited number of times for a suspected transient startup failure. Stop and report the error if the retries are exhausted.
In Task Scheduler, select the task and click Run. Check the task history and the macro's error log, then confirm in Excel that the query results were refreshed as expected.

Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Excel spreadsheets. Its format compatibility helps you move everyday spreadsheet work over easily, although it does not fix Microsoft Excel's Power Query startup or scheduled macro behavior.

Frequently Asked Questions
Why does the macro work after I press Debug and Run?
The pause may give Excel or a required component more time to initialize, but it does not prove that startup timing is the cause. Record the original VBA error and test the refresh manually from Excel's Data tab.
Is a fixed delay enough before refreshing Power Query?
A delay may help in some cases, but startup time varies. Inspect the launch sequence in Task Scheduler and use a bounded retry with error logging rather than relying only on a fixed wait.
Where can I check which account runs the scheduled task?
Open Task Scheduler, select the task, and choose Properties > General. Check the account listed under Security options and verify that it can access the workbook and data sources.
Will WPS Office fix the scheduled Excel Power Query macro?
No. The scheduled macro and Power Query startup behavior belong to Microsoft Excel. WPS Office can be used as an alternative for common spreadsheet work, but the Excel automation should be troubleshot in Excel and Task Scheduler.




