1
votes

Thanks to help from stackoverflow and google+ contributors I now have a working sheet that club members can use to export items in a range of dates from the club calendar into a Google sheets spreadsheet, formatted for printing to PDF and emailing to the other members.

I wanted the script to pop up a dialog so the user could set the range of dates to export, but I couldn't get the new HTML Service to display date pickers (nothing displayed). So I use a form where the newsletter editor can enter the starting monthname and year and the ending ones. I set up a trigger so that when the form response comes in, a script runs, gets the items and formats them in another sheet of the spreadsheet.

But when it is all over, the form response sheet is displayed, not the sheet containing the formatted results.

I have not been able to find out how to bring the results sheet to the front instead of the form responses sheet.

Any ideas?

Here's what I have at the end of my script:

var sheet = ss.getSheetByName("Form Responses 1");
sheet.activate(); 
sheet.setActiveSelection("A1"); 
var sheet = ss.getSheetByName("CalData"); 
sheet.activate(); 
sheet.setActiveSelection("A1");
1

1 Answers

0
votes

You have a duplicate variable assignment to the same variable name, (sheet). You can re-use a variable name, but don't put 'var' in front of any second assignment to the same variable name.

In my original answer, I suggested using the activate method, because you hadn't provided any code. Now you provided code showing that you've already used the activate() method and it isn't working.