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

Returns the main body section of the document for editing.

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.

Snippets using this method

Explore

Related methods

Better Sheets tutorials

Build a Better ChatGPT Prompt Builder

Build a Better ChatGPT Prompt Builder

In this sheet review I take another YouTuber's ChatGPT prompt builder th...

Related blog posts

Written guides about DocumentApp.getBody().

Browse the blog
Big Year 2027 calendar: the whole year on one Google Sheet

Free 2027 calendar.Plan all of 2027 on one Google Sheet, free.

Copy it to your Google Drive.

Free. No password, no card. The sheet link shows up right here.