Skip to content

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.

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 the body.
  • Without body: store the session in an output variable, pass it as session to 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.

ParameterTypeDefaultDescription
pathstring—Path to the existing .docx file.

None.

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.

  • Without body: a ZoanWordSession with the document in memory. Pass it as session to the other Word activities.
  • With body: this activity does not return a value.
Word Open path = asset("letter_template.docx")
└─ body:
Word Find & Replace find = "{CUSTOMER}" replace = customer.name
Word Save path = "C:/letters/" + customer.id + ".docx"
MessageCause 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 packageThe file is not a valid .docx (for example, an old .doc renamed or a damaged file).