Why does Spreadsheet.getActiveSpreadsheet() not properly select the active spreadsheet? I am following google's scripts codelab and came across a tutorial that is not replicable. I am trying to select my active sheet, then duplicate it.
function duplicateAndOrganizeActiveSheet() {
var mySS = SpreadsheetApp.getActiveSpreadsheet();
var duplicateSheet = mySS.duplicateActiveSheet();
}
When executing, this function returns "Exception: Please select an active sheet first." Thus I am not able to duplicate my active sheet.
Any help would be appreciated!
This error occurs when you run the script from the IDE and it does not have a "connection" to the spreadsheet. For example, if you opened the script editor via a direct link and not the main menu.
Try re-opening the attached script via Main Menu -> Extensions -> Apps Script, then run the script again.