Forum Discussion
PDTaylor
Oct 22, 2021Copper Contributor
Excel Script - Refresh data
Hi, I have an excel file which has a data connection. I have been trying to get the data and associated pivot tables to refresh through a script but it doesn't seem to work fully. The script is ...
DirkvH
Nov 15, 2023Copper Contributor
I used your code and it did not work
I did not get an error message but the pivot table just did not refresh
by adding () at the end and it works
sample code
function main(workbook: ExcelScript.Workbook) {
// Refresh Pivot Tables
workbook.refreshAllPivotTables()
}
I know it is a bit late but perhaps someone still has some use for this
😉
😉
BaronK2230
Jul 22, 2024Copper Contributor
does it work for queries?
- SergeiBaklanJul 22, 2024Diamond Contributor
It depends on do we speak about Excel desktop or Excel for web.
On desktop workbook.refreshAllDataConnections() works the same way as Refresh All button.
On web only connections to the sources in the same file or anonymous ODate are refreshed. Why so and could it be resolved is in comments to Power Query Refresh is now generally available in Excel for the web (microsoft.com)