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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Office Script + Power ...
Power Automate
Suggested Answer

Office Script + Power Automate: Power Query doesn’t refresh

(0) ShareShare
ReportReport
Posted on by 8

Hi, I run this Office Script from a Power Automate flow on an Excel file in SharePoint:


function main(workbook: ExcelScript.Workbook) {
workbook.refreshAllDataConnections();
const ws = workbook.getActiveWorksheet();
ws.getRange().getFormat().autofitColumns();
}
 
 

The workbook uses Power Query to load the latest file from a folder (Folder connector → sort by date → keep first).

Power Automate reports success, but the data doesn’t update. It only refreshes when I open the file and do a manual right‑click → Refresh.

Tried:


  • Power BI dataset refresh (pointing to the Excels) → didn’t update the workbook’s queries.

  • Local scheduled refresh every 3 minutes → works locally, but not after saving to SharePoint.

  • Permissions and connections look fine; no concurrent editors.

  •  
 What should I do?
I have the same question (0)
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,150 Super User 2026 Season 1 on at
    Hi,

    Power Automate + Office Scripts cannot refresh Power Query data in a workbook stored on SharePoint or OneDrive.

    The method you’re calling (workbook.refreshAllDataConnections()) doesn’t actually refresh Power Query when run from a cloud flow, so it appears to run but does nothing. Attaching Link for more information Microsoft Learn+1

    Microsoft documentation confirms that refreshing Power Query via a script in Power Automate is not supported, so the data stays stale unless someone manually opens and refreshes the file. Attaching Link for more information Microsoft Learn

    Workarounds include: run a Power Automate Desktop flow on a PC/VM that opens Excel, refreshes the queries, and saves the file;

    move the data refresh into Power BI and then link Excel via Analyze in Excel

    or

    schedule a local script (PowerShell/VBA) to open and refresh

     

    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 959

#2
Valantis Profile Picture

Valantis 872

#3
Haque Profile Picture

Haque 589

Last 30 days Overall leaderboard