Get Active Sheet For Non-Bound Script

17 views
Skip to first unread message

Nibesh Khadka

unread,
Dec 8, 2022, 9:52:19 PM12/8/22
to Google Apps Script Community
Hi
In my add-on, I am fetching a spreadsheet with its id, in a non-bound script. Then I'm trying to get active sheets, I have two sheets.
But it's not working at all, the active sheet is not changing. Is there a solution to it?


let ss = SpreadsheetApp.openById(sheetID);
let activeSheet = ss.getActiveSheet();
let sheetName = activeSheet.getName();

Ed Sambuco

unread,
Dec 8, 2022, 10:48:29 PM12/8/22
to google-apps-sc...@googlegroups.com
You must know the names of the two sheets.  Forget worrying about active, just pull in both sheets:

let sheet1 = ss.getSheetByName('Name1');
let sheet2 = ss.getSheetByName('Name2');

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/25b2759f-7fa0-4c5d-9722-ce45b6290052n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages