Returns the main body section of the document for editing.
class DocumentApp method .getBody()
DocumentApp is the Apps Script service.
.getBody() is the method name you will see after a dot in your code.
What it does
Why it's used
- Reach the main content area to insert or replace text.
- Almost all doc editing flows go through the body.
Common errors
- Forgetting parentheses on getBody. Write DocumentApp.getBody(), not DocumentApp.getBody or getBody by itself.
- Skipping dots between chained calls. Each step needs a dot, like DocumentApp.getActiveDocument().getBody().getBody().
- Adding spaces where they do not belong. Write DocumentApp.getBody(), not DocumentApp .getBody(), DocumentApp.getBody (), or DocumentApp . getBody().
- Wrong capitalization. Use DocumentApp and getBody, not documentapp or getbody.
Explore
Related methods
-
.getText()
Reads the plain text content of a document element.
-
.appendParagraph()
Adds a new paragraph to the end of the document.
-
.setText()
Replaces the text content of a document element.
-
.getActiveDocument()
Returns the Google Doc the user currently has open.
-
.appendTable()
Adds a new table to the end of the document.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about DocumentApp.getBody().
What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →How to Send Google Forms Entries Automatically with Apps Script
Google Forms provides basic email notifications for form submissions, but enhancing these notifications with detailed summaries can significantly improve productivity and response management.
Read post →How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →