Skip to content

Word Activities

Version: 1.0.0  ·  ID: zoan-packages-word  ·  Author: Zoan Software

The Word package reads and creates .docx documents, without the need to have Microsoft Word installed. Its two main uses:

  • Read documents: extract their text, paragraphs and tables for processing.
  • Generate documents: create letters, contracts, reports or minutes from data, combining paragraphs with styles, tables and images.

As in Excel, there are two ways to work:

The read and one-time modification activities accept a path directly: they open the file, do the operation, and close it. Ideal for loose operation.

Word Read Text path = = asset("contrato.docx") → output: texto

For several operations on the same document—and mandatory to build a new document—you open a session with Word Open (existing document) or Word Create (new document), and share that session with the other activities.

Word Create path = "C:/salida/reporte.docx"
└─ body:
Word Append Paragraph text = "Reporte mensual" style = Title
Word Append Table table = = datos

Within body, activities inherit the session automatically, and when the document is finished it is saved and closed alone (with Create) or closed (with Open).

When adding paragraphs with Word Append Paragraph, you can apply a style that gives visual structure to the document:

Estilofor what
TitleThe main title of the document
Heading1 / Heading2 / Heading3Section Headings (Levels)
NormalBody text (default)
ActivityTypeOutputWhat it does
Word Openword-openZoanWordSessionOpen an existing .docx
Word Createword-createZoanWordSessionCreate a new .docx
Word Saveword-saveSave the session to disk
Word Closeword-closeSign out
ActivityTypeOutputWhat it does
Word Read Textword-read-textstringAll document text
Word Read Paragraphsword-read-paragraphsListParagraph List
Word Read Tablesword-read-tablesListTables as DataTables
ActivityTypeOutputWhat it does
Word Append Paragraphword-append-paragraphAdd a paragraph (with style)
Word Append Tableword-append-tableAdd a DataTable as a table
Word Insert Imageword-insert-imageInsert an image
ActivityTypeOutputWhat it does
Word Find & Replaceword-find-replaceintBusca y reemplaza texto
Word Get Propertyword-get-propertyobjectRead metadata (title, author…)
Word Set Propertyword-set-propertyAssign a metadata

Generate a letter from a template with markers:

Copy File source = = asset("plantilla_carta.docx") destination = = "C:/cartas/" + cliente.nit + ".docx" overwrite = true
Word Find & Replace path = = "C:/cartas/" + cliente.nit + ".docx" find = "{NOMBRE}" replace = = cliente.nombre
Word Find & Replace path = = "C:/cartas/" + cliente.nit + ".docx" find = "{FECHA}" replace = = today().ToString("yyyy-MM-dd")