Forum Discussion

Mike_Y_123's avatar
Mike_Y_123
Copper Contributor
May 02, 2024

Office Scripts triggered on sheet activation - to Refresh all data connections

Hi,

I have recorded the below office script that refreshes all data connections. I want this script to run when a sheet named "Delivery date" is activated (i.e. when the user swaps from another sheet to this sheet)

 

It would appear that this is possible, as I found the below help article but I can't get it to work...

https://learn.microsoft.com/en-us/javascript/api/excel/excel.worksheet?view=excel-js-preview#excel-excel-worksheet-onactivated-member

 

function main(workbook: ExcelScript.Workbook) {
  // Refresh all data connections
  workbook.refreshAllDataConnections();
}
 
Thank for your help
Mike
  • JKPieterse's avatar
    JKPieterse
    Silver Contributor
    The documentation you refer to pertains to the Office-JavaScript automation model, which is a different animal than Office Script. You would have to create an Office Add-in to be able to use those events.
    For now, Office Script does not have any events I'm afraid.

Resources