class DocumentApp method .getText()

DocumentApp is the Apps Script service.

.getText() is the method name you will see after a dot in your code.

What it does

Reads the plain text content of a document element.

Why it's used

  • Search a paragraph for a keyword before replacing it.
  • Pull doc content into a sheet for review.

Common errors

  • Forgetting parentheses on getText. Write DocumentApp.getText(), not DocumentApp.getText or getText by itself.
  • Skipping dots between chained calls. Each step needs a dot, like DocumentApp.getActiveDocument().getBody().getText().
  • Adding spaces where they do not belong. Write DocumentApp.getText(), not DocumentApp .getText(), DocumentApp.getText (), or DocumentApp . getText().
  • Wrong capitalization. Use DocumentApp and getText, not documentapp or gettext.

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

Browse the blog