Word Open
Word Open
Section titled “Word Open”Type: word-open · Package: Word Activities v1.0.4 · Output: ZoanWordSession
Opens an existing .docx document and returns a session (ZoanWordSession) that you share with the other Word activities. Use it when you will run several operations on the same document or change it by adding content.
How it works
Section titled “How it works”Reads the whole path file into memory; changes are made on that copy and only reach the disk when you save. The file on disk is not locked while the session is open. You have two modes (see the session model):
- With
body: the activities inside inherit the session automatically; when it ends, the document is closed without saving. If you changed it, call Word Save inside thebody. - Without
body: store the session in an output variable, pass it assessionto the activities, save with Word Save and close it with Word Close.
It only opens .docx (Open XML) documents. For .doc, .rtf or .odt, convert them first, or use Word to PDF if what you need is the PDF. Microsoft Word is not required.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path to the existing .docx file. |
Optional parameters
Section titled “Optional parameters”None.
Sub-flows
Section titled “Sub-flows”body optional
Section titled “body optional”Activities to run with this document. They inherit the session without setting session; on exit, the document is closed without saving (also if an inner activity fails). If omitted (or left empty), the activity returns the session as output.
Output
Section titled “Output”- Without
body: aZoanWordSessionwith the document in memory. Pass it assessionto the other Word activities. - With
body: this activity does not return a value.
Example
Section titled “Example”Word Open path = asset("letter_template.docx") └─ body: Word Find & Replace find = "{CUSTOMER}" replace = customer.name Word Save path = "C:/letters/" + customer.id + ".docx"Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
File not found. | The path does not exist on the machine where the robot runs. Check it with File Exists before opening. |
'path' is required. | path is missing or the expression returned nothing. |
| Error opening the document package | The file is not a valid .docx (for example, an old .doc renamed or a damaged file). |
Related activities
Section titled “Related activities”- Word Create — create a new document.
- Word Save / Word Close — save and close.