
Announcements
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 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