Create a Google Doc file directly in a Google Drive folder

前端 未结 5 1866
离开以前
离开以前 2020-12-19 00:23

How do I create a Google document in a Google Drive folder?

I know that I can create a file in a folder like this.

var folder = DriveApp.createFolder         


        
5条回答
  •  独厮守ぢ
    2020-12-19 01:01

    With document it's a bit different, you first create it then move to the folder:

    var doc = DocumentApp.create('Document Name'),
          docFile = DriveApp.getFileById( doc.getId() );
    
    DriveApp.getFolderById(foldId).addFile( docFile );
    

提交回复
热议问题