Google app
Google Docs
DocumentApp scripts open a Google Doc, reach its body with getBody(), and fill a document with values from Sheet rows.
Choose a task using Google DocsStart with an outcome
Tasks that use Google Docs
Choose the result first. Each card opens a step-by-step guide.
- Google Docs Create a Google Doc from each Sheet row
Create one short Google Doc for each row on a Projects tab that has no document link yet. The script writes the link to the new Doc back into the row.
- Google Docs Fill a Google Doc template from a Sheet row
Make one filled-in copy of a template Doc for each row on a Letters tab. The script swaps {{Name}}, {{Date}}, and {{Amount}} for the values in the row and writes the link to the copy in column D.
Snippets
Snippets for Google Docs
Complete functions you can paste and run one at a time.
Object reference
Objects available in Google Docs
Open an object when you need to get it, try a common action, or inspect exact method signatures.
- Object reference Document
A DocumentApp.Document is the Google Doc file itself. In a script opened from a Doc, getActiveDocument().getBody() returns the active tab. In a standalone script, openById(id).getBody() returns the first tab.
- Object reference Document body
The body holds the main text of one tab in a Google Doc, as a list of paragraphs, headings, tables, and other elements. In a script opened from a Doc, it is the body of the active tab.