


ReplaceText() method shown in the example below. There are many ways to replace text, but the simplest is the (This type of operation is often called a mail
#Google docs data merge full
Spreadsheet full of client information and you want to generate a personalized

The tree below shows which elements can be contained by a certainĮlements shown in bold can be inserted non-bold elements can only beĪpps Script is often used to replace text in Google Docs. However, there are rules about which types of elements can contain other types.įurthermore, the Document Service in Apps Script can only insert certain types Most scripts that modify a Google Doc begin with a call toĬontains all other elements except for the Structure of a documentįrom Apps Script's perspective, a Google Doc is structured much like an HTMLĭocument-that is, a Google Doc is composed of elements (like aĮlements. The script could just as easily make these changes to anĮxisting document by replacing the call toįor scripts created inside a document (container-bound), useĭocumentApp.getActiveDocument(). Paragraph as a heading, and appends a table based on the values in a The script above creates a new document in the user's Google Drive, then insertsĪ paragraph that contains the same text as the document's name, styles that Table.getRow(0).editAsText().setBold(true) Var doc = DocumentApp.create('Sample Document') In either case, it's simple to interact with a Google Doc through Apps Script'sĭocument Service, as the following example To create a container-bound script from within Google Docs, The script special abilities to alter the user interface or respond when theĭocument is opened. Google Apps Script allows you to programmatically create and modify Google Docs,Īs well as customize the user interface with new menus, dialog boxes, andĪpps Script can interact with Google Docs in two broad ways: any script canĬreate or modify a document if the script's user has appropriate permissions for
