Skip to content

Word Read Text

Type: word-read-text  ·  Package: Word Activities v1.0.4  ·  Output: string

Reads all the text of a Word document and returns it as a single string. It is the most direct way to read a document and then extract data with expressions.

Goes through the document body, tables included, and joins its text fragments with line breaks (\n). It accepts session (session mode) or path (quick mode) — see the two modes; with path it opens the file, reads it and closes it without changes.

  • Line breaks: Word stores text in fragments according to formatting, and each fragment goes on its own line. A paragraph with mixed formatting (one word in bold, for example) can end up spread over several lines. If you need exactly one item per paragraph, use Word Read Paragraphs.
  • Scope: only the body; headers and footers are not included.
  • Microsoft Word is not required.

None — but you must provide session or path.

ParameterTypeDefaultDescription
sessionZoanWordSession—Session from Word Open (instead of path). Inherited automatically inside a body.
pathstring—Path to the .docx (quick mode: opens and closes by itself). Only used when there is no session.

Returns a string with all the text. A document with no text returns an empty string ("").

Word Read Text path = asset("contract.docx") → output: text
Set Variable name = term value = regexFind(text, "(?<=Term:\s*)\d+ months")
Log message = "Term found: " + term
MessageCause and fix
'session' or 'path' is required.There is no session and no path.
File not found.The path does not exist on the robot’s machine.
Error opening the document packageThe file is not a valid .docx (for example, an old .doc or a damaged file).