-
Notifications
You must be signed in to change notification settings - Fork 116
command set word
zmworm edited this page Apr 4, 2026
·
28 revisions
Settable elements in Word documents.
| Element | Path | Reference |
|---|---|---|
| Document Root | / |
Word-Document-Set |
| Paragraph | /body/p[N] |
Word-Paragraph-Set |
| Run | /body/p[N]/r[M] |
Word-Run-Set |
| Table / Row / Cell | /body/tbl[N] |
Word-Table-Set |
| Header / Footer |
/header[N], /footer[N]
|
Word-Header-Footer-Set |
| Watermark | /watermark |
Word-Watermark-Set |
| Section | /section[N] |
Word-Section-Set |
| Bookmark | /bookmark[Name] |
Word-Bookmark-Set |
| Footnote / Endnote |
/footnote[N], /endnote[N]
|
Word-Footnote |
| TOC | /toc[N] |
Word-TOC |
| Style | /styles/{StyleId} |
Word-Style-Set |
| Chart | /chart[N] |
Word-Chart-Set |
Use find= to locate text within a document and apply formatting or replace it. The matching text is automatically split into its own run(s) so formatting applies precisely.
Path controls the search scope — use / for the whole document, or a specific path like /body/p[1] to narrow the search.
| Property | Description |
|---|---|
find |
Text to match. Use r"..." prefix for regex (e.g. r"\d+%") |
replace |
Replacement text. Omit to format in-place without replacing |
| All run-level props |
bold, italic, color, highlight, underline, strike, font, size, charSpacing, shading, superscript, subscript, caps, smallCaps, vanish — applied to matched runs |
# Highlight all occurrences of "天气" in paragraph 1
officecli set doc.docx '/body/p[1]' --prop find=天气 --prop highlight=yellow
# Color all percentage values red (regex)
officecli set doc.docx / --prop 'find=r"\d+%"' --prop color=red
# Simple find & replace across the whole document
officecli set doc.docx / --prop find=旧 --prop replace=新
# Find & replace with formatting
officecli set doc.docx '/body/p[1]' --prop find=TODO --prop replace=DONE --prop bold=true- set - Command syntax
- Word Reference - All Word elements
Based on OfficeCLI v1.0.33