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.

Explore

Related methods

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().

Browse the blog