web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate Not Ref...
Power Automate
Suggested Answer

Power Automate Not Refreshing Excel Workbook via Office Scripts

(0) ShareShare
ReportReport
Posted on by 7
I created an office script in Excel to refresh my Power Query connections. The script works just fine but when I try to automate it, the refresh doesn't work. I've tested other scripts (like filtering a column), automating that script, and they work just fine. It's something with the refresh. I did some research into it and loaded everything onto my SharePoint site to connect it that way and to use the "Run Script From SharePoint Library" connector but it still doesn't refresh. 
 
Here's the code in the office script:
function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections
  workbook.refreshAllDataConnections();
  // Refresh all data connections
  workbook.refreshAllDataConnections();
}
 
The reason that there are two refreshes is because there's the connections to source other Excel workbooks and then there's another sheet with some Excel equations. From my experience, when you refresh all, only the connections refresh. You need to refresh the sheets separately or refresh all connections a second time for the Excel equations to update and reflect into a final report.
 
Anyway, here's the flow. All tests have been successful. It's like it will run, skip over the refresh, and then complete. I always receive an email.
 
I've also verified that the script is in the workbook and is pointing to the SharePoint library.
 
How do I fix this?
Categories:
I have the same question (5)
  • Suggested answer
    Ellis Karim Profile Picture
    11,691 Super User 2025 Season 2 on at
     
    According to the documentation: "Unfortunately, refreshing a Power Query data connection in a script run through Power Automate is not currently supported: Troubleshoot Office Scripts running in Power Automate - Office Scripts | Microsoft Learn"
     
    Refresh not fully supported in Power Automate

    Office Scripts can't refresh most data when run in Power Automate. Most refresh methods, such as PivotTable.refresh, do nothing when called in a  flow. Workbook.refreshAllDataConnections only refreshes when PowerBI is the source. Additionally, Power Automate doesn't trigger a data refresh for formulas that use workbook links.

    Troubleshoot Office Scripts running in Power Automate - Office Scripts | Microsoft Learn

    Script methods that do nothing in Power Automate flows

    The following methods do nothing in a script when called through Power Automate. They still return successfully and don't throw any errors.

    Class Method
    PivotTable refresh
    Workbook refreshAllPivotTables
    Worksheet refreshAllPivotTables

     

    Ellis Karim Ellis Karim
    Blog | LinkedIn | Bluesky

  • renee_crozier Profile Picture
    7 on at
    @Ellis Karim Yes, I read that but I also read that if you were to upload and run it from SharePoint, it would work. Do you know of a workaround where I can do this via Power Automate and possibly leave out the office script? 
  • Ellis Karim Profile Picture
    11,691 Super User 2025 Season 2 on at
     
    I did try running the script from a shared location in SharePoint, but the results were the same: the workbook didn't refresh. Unfortunately, I didn't find a  solution.  See:  Workbook.refreshAllDataConnections() is not supported in Power Automate. - Microsoft Q&A

     
    I did find the following blog:
     
     
     

    Ellis Karim Ellis Karim
    Blog | LinkedIn | Bluesky

  • Suggested answer
    takolota1 Profile Picture
    4,974 Moderator on at
    If you need to refresh a lot of Excel data in the back-ground you can try putting the data in regular tables & then using Excel batch actions to update the tables.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard