I have dozens of Excel workbooks that need to be updated daily so that our employees have up-to-date data for their day-to-day work. These workbooks keep our employees from having to spend all day clicking around in our ERP system trying to find the data. These workbooks consolidate the data needed on a day-to-day basis.
Each user workbook has a Power Query query in each one that pulls in the new data.
However, I have not yet been able to find a way to refresh each workbook programmatically, meaning without having to open each workbook.
The source for the Power Query queries is an Excel Workbook on a SharePoint site.
To refresh the query manually takes between 1-55 minutes depending on the workbook due to them using different data sources.
And, no, the end user cannot update the queries for themselves because they 1. won't have access to the underlying data and 2. won't have the patience to wait for the query to refresh.
Ideally, on a nightly basis each workbook will have its Power Query queries refreshed so that when the end user opens up the workbook in the morning, the workbook has the refreshed data already included.
I've tried VBA. The results are unreliable at best because I'm not able to get the script to wait until the query is fully refreshed before save/close.
I've tried Power Automate. The results are unreliable at best because I'm not able to get it to make sure and wait until the query is fully refreshed before save/close.
I've tried Microsoft Graph API. However, I cannot seem to find a refresh command that will refresh Power Query.
Other options I'm considering include:
Excel Javascript API
Office Online Server
Office Data Connection File
Excel Primary Interop Assembly
Excel Web Access Web Part
Note: I know little about these other options at the moment so please excuse any that are nonsensical for this use case.