Refresh Excel PivotTables with Office Scripts and Power Automate
Question details
The user needs to refresh Excel data connections and their related PivotTables using an Office Script in Power Automate.

- Product
- Microsoft Excel, Office Scripts, and Power Automate
- Device & OS
- not provided
- Scenario
- A Power Automate flow runs an Office Script against a workbook with data connections and PivotTables.
- Observed behavior
- The script runs without an error, but the related PivotTables do not update.
Open the workbook in Excel and identify the PivotTables and their source data connections. Check Microsoft's current Office Scripts data refresh limitations for Power Automate, since support can vary by refresh method and data source.
Correct the PivotTable refresh call in the Office Script
Use parentheses to invoke the refresh method, then test the script in a supported Excel environment.
Calling the method correctly is necessary, but it does not override Power Automate's Office Scripts refresh limitations. Microsoft documents that PivotTable refresh methods do nothing when called through Power Automate.
In Excel for the web, open the workbook, select Automate, and open the script in the Code Editor.
In the main function, add the method call with parentheses: workbook.refreshAllPivotTables();
Save and run the script from Excel, then check the PivotTable values against the source data. If the script is run through Power Automate, do not assume a successful flow means the PivotTables refreshed.

Refresh the data and PivotTables in desktop Excel
Use Excel's refresh controls when the Power Automate script cannot perform the required refresh.
Work with spreadsheets and PivotTables in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Excel format compatibility for an easier transition. It does not fix Microsoft's Office Scripts or Power Automate refresh limitations.

Frequently Asked Questions
Why does my PivotTable stay unchanged when the Power Automate flow succeeds?
A successful script run does not guarantee a refresh. Microsoft documents that Office Scripts PivotTable refresh methods do nothing when called through Power Automate. Check the current limitations and refresh the workbook in a supported environment.
How do I call refreshAllPivotTables correctly?
In the Office Scripts Code Editor, use workbook.refreshAllPivotTables(); inside the main function. Without parentheses, the method is referenced rather than invoked.
Can an Office Script refresh a Power Query in Power Automate?
Do not assume it can. Office Scripts data refresh support in Power Automate is limited and depends on the method and source. Check Microsoft's current documentation for your specific connection.
How can I refresh a PivotTable manually?
In desktop Excel, refresh the source from Data > Refresh All. Once the source finishes updating, right-click the PivotTable and select Refresh if needed.




