I’m somewhat new to scripting so would be extremely grateful to anybody who could provide an insight to my problem. For some reason I’m unable to get the Google script below to trigger onOpen for my Google Apps spreadsheet.
The sheets in my spreadsheet range from January to December from left to right. The script is meant to identify the current month number, then use that number to identify and set the active sheet for that month when the spreadsheet is opened. I’ve taken it verbatim from another thread: Google Apps Spreadsheet open specific sheet based on current date (Month)
I’m simply creating a new spreadsheet, selecting Script Editor from the Tools drop-down, then pasting in the below script and saving it.
/**
* Selects a monthly sheet
*/
function onOpen() {
var month = (new Date()).getMonth();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[month];
ss.setActiveSheet(sheet);
};
Have tried both naming it onOpen, and adding an onOpen trigger to the function after renaming it. I’m able to get other onOpen events to trigger when the spreadsheet is opened, but sadly this one only works if I trigger it manually from the script editor.
Cheers.