Skip to content

Word Find & Replace

Type: word-find-replace  ·  Package: Word Activities v1.0.0  ·  Output: int

Searches for text and replaces it throughout the document. Returns how many replacements it made. It’s the basis of the templates pattern: you take a .docx with markers ({NOMBRE}, {FECHA}) and replace them with real data to generate custom documents.

Replaces all occurrences of find with replace. By default case insensitive (caseSensitive = false). Accepts session or path (in path mode, opens, modifies and saves automatically). Returns the number of replacements.

ParameterEditorDescription
findexpressionTexto a buscar.
replaceexpressionTexto de reemplazo.
ParameterEditorDescription
sessionsessionWord Open session (instead of path).
pathexpressionPath to .docx (quick mode: open, modify and save only).
caseSensitivebooleanCase sensitive. By default false.

Returns a int with the number of replacements made.

Fill out a letter template with multiple markers:

Copy File source = = asset("plantilla.docx") destination = = rutaCarta overwrite = true
Word Open path = = rutaCarta
└─ body:
Word Find & Replace find = "{NOMBRE}" replace = = cliente.nombre
Word Find & Replace find = "{FECHA}" replace = = today().ToString("dd/MM/yyyy")
Word Find & Replace find = "{MONTO}" replace = = toString(monto)
Word Save