Forum Discussion
Setting Default Worksheet using Office Scripts
I'm working on an office script for Excel that generates the file as I want it, but for some reason, the file automatically opens up to the last sheet in the lineup instead of the first. I've tried a few methods like .activate() but they don't seem to work; only opening the file manually, switching to the first sheet, and saving does. Switching sheets also doesn't show up in when recording actions. Is there a command or method to make sure the file automatically opens up to the first sheet after my script is done setting up the document?
2 Replies
- JKPieterseSilver Contributor
As far as I know, all you would need in your script (at the end) are these two statements:
let sht = workbook.getFirstWorksheet(); sht.activate();
- SergeiBaklanDiamond Contributor
To be sure, do you work with Office Scripts or Office.js ? Office Scripts doesn't work with files and doesn't support workbook-level events.