Word Read Text
Word Read Text
Section titled “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.
How it works
Section titled “How it works”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.
Required parameters
Section titled “Required parameters”None — but you must provide session or path.
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanWordSession | — | Session from Word Open (instead of path). Inherited automatically inside a body. |
path | string | — | Path to the .docx (quick mode: opens and closes by itself). Only used when there is no session. |
Output
Section titled “Output”Returns a string with all the text. A document with no text returns an empty string ("").
Example
Section titled “Example”Word Read Text path = asset("contract.docx") → output: textSet Variable name = term value = regexFind(text, "(?<=Term:\s*)\d+ months")Log message = "Term found: " + termCommon errors
Section titled “Common errors”| Message | Cause 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 package | The file is not a valid .docx (for example, an old .doc or a damaged file). |
Related activities
Section titled “Related activities”- Word Read Paragraphs — the text split by paragraph.
- Word Read Tables — extract the tables.
- Word Find & Replace — change the text.