So I am trying to get my gsheet script to run on an activesheet in a specific document.
If I do;
function get_name() {
let ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
Logger.log(ss);
}
It returns name of whichever sheet is 'active', meaning if there are three sheets (sheet1, sheet2, sheet3) and I run the code when I am on sheet2, it will display "sheet2".
But if I do;
function get_name() {
let ss = SpreadsheetApp.openById("idispastedhere").getActiveSheet().getName();
Logger.log(ss);
}
It returns the sheet that is first in order. So say the order is (sheet1, sheet2 and sheet3) and I am on sheet2, it will return "sheet1".
Could somebody explain why this happens?