I know I can use

var doc = DocumentApp.getActiveDocument();

to create a new document on GoogleDocs, but how do I create it on a specific folder?

Further more, how do I write a code to open the newly created document? I´ve searched https://developers.google.com/apps-script/reference/document/document-app#create(String), but I could not find the answer.

Thank You Very Much!

有帮助吗?

解决方案

your code can get an instance of an already existing Document, and is used for script running "inside" the document (custom options, functions, etc.)

To create a new document instead, use:

// Create and open a document.
doc = DocumentApp.create('Document Name');

this works in any script.

To move the document on a specific folder, you have the method:

myFolder.addFile(doc);

For more info, look at DriveApp, DocumentApp, Document, File, Folder reference.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top