Fix Power Query Refresh Failing in Excel Office Scripts
Question details
The user needs to understand why calling refreshAllDataConnections() from an Office Script in Power Automate fails to refresh Power Query results, and how to resolve or work around this limitation.

- Product
- Microsoft Excel, Power Automate
- Device & OS
- not provided
- Scenario
- Attempting to automate the refresh of Power Query data connections using an Office Script triggered by a Power Automate flow.
- Observed behavior
- The workbook.refreshAllDataConnections() method does not successfully refresh the Power Query results due to compatibility and authentication limitations in Excel for the web.
Verify the type of data connection used in your Power Query setup and ensure you have access to native Power Automate connectors, as Excel for the web currently limits authenticated data source refreshes via scripts.
Use Native Power Automate Connectors Instead of Office Scripts
Bypass the Office Script limitation by using native Power Automate connectors to fetch and update your data securely.
Excel for the web, which Power Automate uses to execute Office Scripts, does not support the workbook.refreshAllDataConnections() method for most authenticated data sources. Trying to force a refresh this way will cause the flow to fail or silently skip the update.
The most reliable workaround is to shift the data retrieval workload from Excel's Power Query directly to Power Automate's native connectors.
Determine where your Power Query data originates (e.g., SQL Server, SharePoint List, Dataverse).
Open your Power Automate flow editor and click 'Add an action'. Search for and select the native connector that corresponds to your database or data source to retrieve the data.
Use the 'Excel Online (Business) - Add a row into a table' action within an 'Apply to each' loop to insert the retrieved data directly into your target workbook, bypassing the need for a Power Query refresh entirely.

Refresh Data Connections Manually in Excel Desktop
If you must maintain your existing Power Query setup, use the desktop version of Excel to execute the data refresh.
Switch to WPS Office for a Seamless Spreadsheet Experience
Dealing with complex script limitations and unsupported features in Microsoft Excel for the web can disrupt your workflow. WPS Office provides a free, lightweight, and highly compatible alternative for your daily spreadsheet and data analysis needs. Enjoy a familiar interface and excellent compatibility without the heavy technical overhead.
- 1. Download the software: Visit the official WPS website and click 'Download WPS Office Free'.
- 2. Install and launch: Follow the installation prompts and open the WPS Spreadsheet application.
- 3. Open existing files: Open your standard .xlsx workbooks directly; all your existing formatting and basic data remain perfectly intact.
- 4. Manage your data: Utilize the intuitive ribbon interface to analyze, filter, and process your daily data tasks effortlessly.

Frequently Asked Questions
Why does workbook.refreshAllDataConnections() work on Excel Desktop but not in Power Automate?
Power Automate relies on Excel for the web to execute Office Scripts. Excel for the web currently has strict limitations regarding authenticated Power Query external data sources and does not support full connection refreshes through scripting like the desktop version does.
Can I automatically refresh Power Query in Excel for the web at all?
Automatic refresh in Excel for the web is heavily restricted. It typically only works for anonymous, publicly accessible data sources or specific organizational setups natively supported without complex authentication prompts.
Are there other tools to automate Microsoft data refreshes effectively?
Yes. If Power Automate and Excel for the web cannot refresh your specific dataset, consider using Power BI to handle complex data modeling and scheduled refreshes, as it is designed specifically for robust automated data pipelines.




