I am trying to run an Excel Office Script to perform a "refresh all". However, even though it says its run, the file does not refresh. One of my files takes a while to refresh so I'd like to put a pause or sleep into the script. I can't use VBA as Power Automate does not like macro-enabled workbooks.
This is the normal script:
function main(workbook: ExcelScript.Workbook) {
// Refresh all data connections
workbook.refreshAllDataConnections();
}
This is the one I tried to add a sleep to:
function main(workbook: ExcelScript.Workbook) {
// Refresh all data connections
workbook.refreshAllDataConnections();
sleep(20);
}
function sleep(seconds: number) { let waitUntil = new Date().getTime() + (seconds * 1000);
while (new Date().getTime() < waitUntil) { };
}