Skip to content

word reference

zmworm edited this page Mar 27, 2026 · 55 revisions

Word (.docx) Reference

Complete reference for OfficeCLI operations on Word documents.

Elements

Element Path Operations
Document / set
Paragraph /body/p[N] add, set
Run /body/p[N]/r[M] add, set
Table /body/tbl[N] add, set
Header/Footer /header[N], /footer[N] add, set
Watermark /watermark add, set
Section /section[N] add, set
Picture (inline/floating) add
Bookmark /bookmark[Name] add, set
Footnote/Endnote /footnote[N], /endnote[N] add, remove
Hyperlink (inline) add
Comment (attached) add
TOC /toc[N] add, remove
Equation (inline/block) add
Style /styles/{StyleId} add, set
Chart /chart[N] add, set, remove
Field (inline) add
Break (inline) add
SDT/Content Control /body/sdt[N] add, set, remove

Path Aliases

Human-friendly path names are accepted as aliases:

Alias Short Form Example
paragraph p /body/paragraph[1] = /body/p[1]
run r /body/p[1]/run[1] = /body/p[1]/r[1]
table tbl /body/table[1] = /body/tbl[1]
row tr /body/tbl[1]/row[1] = /body/tbl[1]/tr[1]
cell tc /body/tbl[1]/tr[1]/cell[1] = /body/tbl[1]/tr[1]/tc[1]

Track Changes

Accept or reject all tracked changes in a document:

# Accept all changes (apply insertions, remove deletions)
officecli set report.docx / --prop accept-changes=all

# Reject all changes (remove insertions, restore deletions)
officecli set report.docx / --prop reject-changes=all

Handles: insertions, deletions, formatting changes, section/table/paragraph property changes, move markers.

Hyperlink Set

Modify hyperlink target and display text:

officecli set report.docx /body/p[1]/hyperlink[1] --prop url=https://example.com --prop text="Click here"

Properties: url/link/href (target URI), text (display text).

Raw XML Parts

For low-level operations using the raw and raw-set commands:

Part Path Description
/document (default) Main document body XML
/styles Style definitions XML
/numbering List/numbering definitions
/settings Document settings
/header[N] Header XML (0-based for raw)
/footer[N] Footer XML (0-based for raw)

XPath namespace prefixes: w (WordprocessingML), r (Relationships), a (DrawingML), mc (Markup Compatibility), wp (Word Drawing), wps (Word Drawing Shape), v (VML)

# View raw document XML
officecli raw report.docx /document

# Remove all bold from document
officecli raw-set report.docx /document --xpath "//w:b" --action remove

# Set justification via raw XML
officecli raw-set report.docx /document --xpath "//w:pPr/w:jc" --action setattr --xml "w:val=center"

Copy Elements

# Copy a paragraph
officecli add report.docx /body --from /body/p[1]

# Copy a table
officecli add report.docx /body --from /body/tbl[1] --index 0

Based on OfficeCLI v1.0.24

Clone this wiki locally