Install
openclaw skills install word-track-changesEnable Microsoft Word's Track Changes (修订模式) on documents using native OOXML elements. Supports cross-run text matching and precise paragraph-level replacement. Use when agents need to modify Word documents with tracked changes that show up as insertions (green) and deletions (red strikethrough) in Word's Review pane. Handles real-world DOCX files where text is split across multiple w:t nodes.
openclaw skills install word-track-changesEnable native Microsoft Word Track Changes functionality using OpenXML. Handles real-world DOCX files where text is split across multiple <w:t> nodes.
Use this skill when you need to:
<w:r> / <w:t> elementspython ~/.openclaw/skills/word-track-changes/scripts/enable_tracking.py input.docx output.docx
from track_changes import TrackChangesProcessor
p = TrackChangesProcessor("document.docx")
p.set_author("Agent")
p.replace_text_with_revision(
old_text="existing text to replace",
new_text="new text with revision mark"
)
p.save("output.docx")
p.cleanup()
from track_changes import TrackChangesProcessor
p = TrackChangesProcessor("document.docx")
p.set_author("Agent")
p.insert_paragraph_after(
search_text="text before new paragraph",
new_text="New paragraph shown as insertion."
)
p.save("output.docx")
p.cleanup()
from track_changes import batch_revisions
revisions = [
{"type": "replace", "old": "old text 1", "new": "new text 1"},
{"type": "insert_after", "search": "anchor text", "new": "inserted paragraph"},
]
batch_revisions(
"input.docx",
revisions,
author="Agent",
output_path="output.docx"
)
| Capability | Description |
|---|---|
| Cross-Run Matching | Finds text even when Word splits it across multiple <w:t> nodes |
| Paragraph-Level Precision | Only replaces the target text within its paragraph, preserving all other content |
| Format Preservation | Copies existing run properties (<w:rPr>) for consistent font/style |
| Batch Revisions | Apply multiple tracked changes in a single pass |
| Track Changes Settings | Automatically enables trackRevisions in settings.xml |
<w:ins> — Insertion mark (green, underlined)<w:del> — Deletion mark (red strikethrough)<w:delText> — Deleted text contentDOCX (ZIP archive)
├── word/document.xml ← Main content (modified with revision marks)
├── word/settings.xml ← Track changes settings (updated if needed)
└── ...
The processor:
word/document.xml<w:t> nodes<w:ins> / <w:del> at the exact positionAll scripts are in scripts/ directory:
| Script | Purpose |
|---|---|
track_changes.py | Core library with TrackChangesProcessor |
enable_tracking.py | CLI tool to enable track changes |
insert_revision.py | CLI tool to replace text with revision marks |
delete_revision.py | CLI tool to mark text for deletion |
batch_revisions.py | CLI tool for processing multiple revisions from stdin |
TrackChangesProcessor(docx_path)Main class for processing a DOCX file.
set_author(author) — Set the revision author name.replace_text_with_revision(old_text, new_text) — Replace text inside a paragraph with tracked changes. Raises ValueError if old_text is not found.insert_paragraph_after(search_text, new_text) — Insert a new paragraph after the paragraph containing search_text, marked as <w:ins>.enable_track_changes() — Update word/settings.xml to enable track revisions.save(output_path) — Write the modified DOCX.cleanup() — Remove temporary files.enable_track_changes(input, output)insert_text_with_revision(input, search, new, author, output)mark_deletion(input, target, author, output)batch_revisions(input, revisions, author, output)See example_usage.py for a complete working example.