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 / 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
    3,860 Super User 2025 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

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard