Sample Code Google Apps Script

Create a Doc on the fly function myFunction1() {const doc = DocumentApp.create(‘Test 1’);} Create a Doc add some content function myFunction2(){const doc = DocumentApp.create(‘Test 2’);const body = doc.getBody();Logger.log(body);body.appendParagraph(‘Hello World’);} Select a Doc add content to existing Google Doc function myFunction3(){const id = ‘1Rznazp0sPf9eSxFmHRHrWFK0H4lmju6FXDbuI3gZwLk’;const doc = DocumentApp.openById(id);const body = doc.getBody();const para = body.appendParagraph(‘Hello World 2’);para.appendText(‘new text’);Logger.log(para);} … Read more