Fix Power Automate TypeScript Script Not Refreshing Excel Data
Question details
The user needs to fix an issue where an Office TypeScript script successfully refreshes Excel data locally but fails when executed via Power Automate.

- Product
- Microsoft Excel, Power Automate
- Device & OS
- not provided
- Scenario
- Automating an Excel data connection refresh using an Office Script within a Power Automate workflow integrated with Dataverse.
- Observed behavior
- The external data connection refreshes correctly when the script is run manually inside the Excel desktop or web app, but fails to refresh the data when triggered in the background via Power Automate.
Verify that your Power Automate service account has the correct permissions to access the Excel file in SharePoint or OneDrive, and ensure that your external data sources do not require active user authentication prompts.
Check Office Scripts Background Execution Limitations
Determine if your specific data refresh operation is supported by Office Scripts when running in the background without an active user session.
The primary reason an Office Script fails in Power Automate while succeeding in Excel is the lack of an active user session. Power Automate executes scripts in the background, which restricts authentication capabilities. Many external data connections (such as Dataverse or Power Query) require active user credentials and will be blocked during unattended background execution.
Open your Excel workbook. Navigate to the 'Data' tab and select 'Queries & Connections' to check the type and authentication method of your external data connection.
Confirm whether the connection type relies on Single Sign-On (SSO) or prompts for credentials. Background operations via Power Automate cannot handle interactive credential prompts.
Since this involves multi-application integration (Excel, Dataverse, Power Automate), visit the Microsoft Power Platform Community forums or contact Microsoft Support. Provide your workbook, the specific TypeScript code, and your flow details for specialized troubleshooting.

Use Native Power Automate Actions Instead of Scripts
Bypass the Office Script limitation by using native Power Automate connectors to fetch Dataverse data and update Excel directly.
Try WPS Office for Lightweight Excel Spreadsheet Management
While advanced cloud automation tools like Power Automate are specific to the Microsoft ecosystem, WPS Office provides a free, lightning-fast alternative for everyday spreadsheet tasks. If your data doesn't require complex background automation, WPS Office offers robust tools for managing and analyzing large datasets seamlessly.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installation package for Windows, Mac, or Linux.
- 2. Install the Suite: Run the installer and follow the simple on-screen instructions to set up the software in minutes.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheet and easily open your existing .xlsx files. All local data connections and standard formulas will function as expected.

Frequently Asked Questions
Why does my Office Script work locally in Excel but fail in Power Automate?
When you run a script manually in Excel, it uses your active user session to authenticate external data connections. Power Automate runs the script in the background without user interaction, which prevents the script from authenticating against external sources like Dataverse.
Does Power Automate have a native action to refresh Excel data connections?
No, Power Automate does not currently feature a direct, native action to trigger an Excel 'Refresh All' for Power Query or external data connections in the background.
Do I have to use TypeScript to automate Excel tasks?
No. Many automation tasks, such as adding rows, updating cells, or deleting data, can be performed using the native 'Excel Online (Business)' connectors within Power Automate, eliminating the need to write custom TypeScript Office Scripts.
Where can I report Office Script integration bugs?
You can report bugs or request assistance in the Microsoft Power Platform Community forums, or by submitting a support ticket through your Microsoft 365 Admin Center, including logs of your workflow and script errors.




