Word Application and Open Documents
word_appSave or close Word documents, insert at cursor, toggle track changes, compare or merge files, convert PDFs, refresh fields, run proofing/readability checks, and repair live edits.
Instructions
Needs Microsoft Word itself: save or close a document open in Word, insert at the user's cursor, switch track changes on an open document, scroll Word to a spot, export to and import from PDF, compare, combine or merge documents, refresh fields, Word's proofing and readability statistics, the opens-clean check, and repair after a crashed live edit. Text edits to an open document go through word_edit and reads through word_read. Live edits stay unsaved until com_save_document; the other com_ ops work in a private hidden Word and never change the source file, except com_refresh_fields, which saves it in place. On a document open in Word, switch track changes on (live_set_track_changes) before editing, and save (com_save_document) last. Ops, one per line, as name(required; opt optional): what it does. file_path, live and backup are not repeated; word_help shows them:
com_save_document(opt save close password output_path): Save or close a document open in Word, or save an encrypted copy; close with save=false discards unsaved changes.
live_insert_at_cursor(text; opt newline): Insert text at the user's cursor position in the open document (main body text only; headers, footers, and footnotes not supported).
live_set_track_changes(enabled): Turn track changes on or off in the open document; the setting stays unsaved until com_save_document (set_track_changes for a closed file).
com_refresh_fields(): Update every field (TOC, page references, captions, cross-references) in a hidden Word; this saves the file in place. Header/footer PAGE and NUMPAGES keep their cached values; Word recomputes them at layout.
com_validate_opens_clean(opt timeout): Open the file in a hidden Word and report whether it opens clean, with Word's own error if it does not. More ops follow, in the same format, in the op parameter's description.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | The operation to run: an op listed in this tool's description, or one of these, in the same format: - com_multi_document(action, files; opt output_path author section_break_between timeout): Compare two drafts into a redline, combine two reviewers' changes, or merge documents into one new file (action). - com_import_pdf(pdf_path; opt output_path): Convert a PDF to .docx via Word's built-in PDF reflow, in a dedicated invisible Word instance. - com_export_pdf(opt pdf_path overwrite): Export the document to PDF via an invisible Word instance with full fidelity (fields resolved, footnotes, TOC, headers/footers, images). - live_scroll_to(opt find paragraph_index): Scroll the user's Word window to show a location without selecting anything or moving their cursor (useful after a live edit, to show the user what changed). - live_repair(): Repair Word after a crashed live edit (screen updating off, alerts off, an open undo record); safe to run at any time. - com_proofing_errors(opt limit timeout): List Word's spelling and grammar errors with context and suggestions; the file must be closed in Word. - com_readability_statistics(opt timeout): Read Word's readability statistics (Flesch scores, counts and averages); the file must be closed in Word. - update_now(): Install the newer version the update notice named; call only when the user asks or agrees. - update_notices(action): Turn update notices on or off, or show their status (action). | |
| args | No | The op's arguments as an object. Include file_path (the absolute .docx path) unless the op's line names other paths or the op reads no document; unknown keys are refused. word_help lists every argument. |