Forum Discussion

PDTaylor's avatar
PDTaylor
Copper Contributor
Oct 22, 2021

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 as follows:

 

function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections

 

  workbook.refreshAllDataConnections();
  workbook.refreshAllPivotTables
  }
 
I am prompting the script to run through PowerAutomate a couple of times a day. The file will appear to be modified (last modified date of file reflects when the script was last run through PowerAutomate) but the data in the Pivot table is not up to date from the data source.
 
If I open the file online will get a message to enable the queries so I don't know if this needs to be part of the script too?
 

 

Any thoughts? 
 
Thanks

Share

Resources