title: Google Apps Script. Setting an active sheet (focus) in another spreadsheet.
body: <p>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?</p>
  
  <pre><code>          var numsh = dest_ss.getNumSheets();
            for (var i = 0; i &lt; numsh-1; i++) {
            dest_ss.deleteSheet(dest_ss.getSheets()[dest_ss.getNumSheets() - 1]);
            }
  </code></pre>