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,214 Super User 2026 Season 2 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 273 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 175 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 146 Super User 2026 Season 2

Last 30 days Overall leaderboard