I have this script which deletes all but the first sheet in another spreadsheet. It works fine, but if in the other spreadsheet the focus is not in the first sheet, the other spreadsheet crashes and has to be reloaded. Not a problem, everything still works OK, but a nuisance. How can I make the first sheet have input focus before deleting all but the first sheet?
var numsh = dest_ss.getNumSheets();
for (var i = 0; i < numsh-1; i++) {
dest_ss.deleteSheet(dest_ss.getSheets()[dest_ss.getNumSheets() - 1]);
}