سؤال

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