I've used this script to create a Google Document (like word document) with Google Spreadsheet. But, when I do so, the new text document created from a template is placed in the default chosen folder. And, after that, I have to go to that folder, find the new document and open it.
The million dollar question is: how could I make the newly created text document to automatically open? I think that if it wasn't a Google text Document but a spreadsheet I should use SpreadsheetApp.getActive()
. Is there a document equivalent of .getActive()
?.
Best Answer
I've found no direct way of opening a created document through Google Apps Script (GAS), via GAS. There's however an indirect way, which is presented below. It uses an Anchor element to show a pre-formatted hyperlink.
Code
Screenshot
Remarks
This piece of code creates a new menu entry called "Extra" upon opening of the file. The selection "Create Document" will create (in the back gound) a Google Document and displays a panel with a hyperlink to open the document.
Example
I've created an example file for you: How To Open Document