replace_text changes wording in place: it finds the text, replaces it, keeps the fonts, tables, images and layout, and saves an edited copy — reporting how many occurrences changed. wholeWord, matchCase (default true) and regex (with $1 group references) control the match; worksheet or slide picks the part of a workbook or presentation; format converts while editing. Example prompt: “Replace ACME Corp with Globex Ltd in contract.docx.”
Tool description (as the AI agent sees it):
Finds and replaces text in a document and saves an edited copy, keeping the document’s formatting, tables, images and layout. Use it whenever the user asks to change, rename, update or correct wording in a Word, Excel, PowerPoint, PDF or text document. Supports DOCX, DOC, RTF, ODT, XLSX, XLS, ODS, CSV, PPTX, PPT, ODP, PDF, TXT, Markdown, EPUB and more. Spreadsheets and presentations are edited one worksheet or slide at a time (1-based, default 1) and every other part is kept. Do NOT pre-check whether files exist — just pass the filename the user provided; a missing file returns the list of available files. Matching is case-sensitive by default; set matchCase=false, wholeWord=true or regex=true as needed. A phrase split across differently formatted runs is not matched — use extract_html and save_from_html for those edits. Returns ‘Replaced N occurrence(s) …’ and the saved path (‘Saved to: …’) of ‘_edited.’. When nothing matches it returns ‘Text replacement found no matches …’ and writes no file. On failure isError is set and the text starts with ‘Text replacement failed for’; a file that cannot be found returns the list of available files instead.
Plain text — captured from server 26.10.0 (the server prints the full path inside your storage folder):
Evaluation mode: outputs start with an evaluation banner, saved workbooks gain
an extra worksheet, and only the first 2 PDF pages, worksheets and slides can
be edited. Set GROUPDOCS_LICENSE_PATH, or the metered keys, to remove these
limits.
Replaced 6 occurrence(s) of 'ACME Corp' in 'contract.docx'
Saved to: …/contract_edited.docx
(The first paragraph is one line in the response, wrapped here for width; it appears only in evaluation mode.)
Nothing matched, nothing written — a find that matches nothing is an answer, not a failure:
Text replacement found no matches for 'Initech' in 'contract.docx'. No file was
written.
One part of a workbook or presentation per call — the response names it:
Replaced 1 occurrence(s) of 'ACME Corp' in worksheet 1 of 3 of 'budget.xlsx'
Replaced 1 occurrence(s) of 'ACME Corp' in slide 1 of 3 of 'review.pptx'
The copy is saved as <name>_edited.<ext> (or outputName) in the output folder’s root, even when the input sits in a sub-folder. With format: "pdf" the edited copy is a PDF.
Matching works within one formatting run: a phrase half in italics is not found. In the capture above, the document held 7 occurrences; the 7th was split across two runs and stayed unchanged. Use extract_html for such phrases.
On failure the text starts with Text replacement failed for and isError is set — for example, in evaluation mode:
Text replacement failed for 'review.pptx' (find='ACME Corp'): Evaluation mode
edits only the first 2 slides of a presentation; slide 3 is beyond them. Set
GROUPDOCS_LICENSE_PATH, or the metered keys, to edit every part.
Example prompts
“Replace ACME Corp with Globex Ltd in contract.docx and keep the formatting.”
“Change every v2.3 to v2.4 in the NDA — whole versions only.”
“Rename the supplier on the first worksheet of budget.xlsx.”
“Fix the typo ‘recieve’ in all of these documents.”