-
Notifications
You must be signed in to change notification settings - Fork 465
word reference
Complete reference for OfficeCLI operations on Word documents.
| 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, set, get |
| OLE Object |
/body/ole[N], /header[N]/ole[M], /footer[N]/ole[M]
|
add, set, get, query, remove |
| 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 |
| Numbering |
/numbering/abstractNum[@id=N], /numbering/num[@id=N], /.../level[L]
|
add (abstractNum/num/lvl/tab), set, get, query, remove |
| Chart | /chart[N] |
add, set, remove |
| Field | (inline) | add |
| Break | (inline) | add |
| SDT/Content Control | /body/sdt[N] |
add, set, remove |
| Form Field |
/formfield[N] or /formfield[Name]
|
add, set, get |
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]
|
Paragraphs have auto-assigned w14:paraId and w14:textId for stable addressing across edits:
| Path | Description |
|---|---|
/body/p[@paraId=XXXXXXXX] |
Navigate to paragraph by paraId |
/body/p[@textId=XXXXXXXX] |
Navigate to paragraph by textId |
/picture[@id=N] |
Navigate to picture by docPr ID |
/chart[@id=N] |
Navigate to chart by docPr ID |
/comments/c[@commentId=N] |
Navigate to comment by commentId |
/body/sdt[@sdtId=N] |
Navigate to SDT/content control by sdtId |
-
paraIdis assigned on creation and preserved across edits -
textIdrefreshes when paragraph content changes (set, find-replace, add/remove run) -
docPrIDs are auto-deduped on open - Get output now returns stable ID paths (e.g.,
p[@paraId=...]instead ofp[N])
get / enumerates these root-level containers (mirroring the /numbering pattern). This is the surface that dump walks when emitting a replayable batch script:
-
/body— main document body -
/styles— style table -
/numbering— list templates -
/comments— comments part (excludes separator/continuation system rows) -
/footnotes— footnotes part (excludes separator/continuation system rows) -
/endnotes— endnotes part (excludes separator/continuation system rows)
Inline section breaks inside the body are surfaced on the relevant paragraph's Get output so dump can replay them in document order.
For OOXML attributes not exposed as first-class properties, OfficeCLI accepts dotted paths that mirror the OOXML element hierarchy. The fallback works on all Word elements via add and set: paragraph, run, table, row, cell, section, styles, header/footer.
# Set a deep paragraph property
officecli set report.docx /body/p[1] --prop pPr.spacing.lineRule=auto
# Set a run property
officecli set report.docx '/body/p[1]/r[1]' --prop rPr.bdr.val=singleValues are validated for known enum / long-tail boolean attributes. Unknown attributes write through as raw XML.
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=allHandles: insertions, deletions, formatting changes, section/table/paragraph property changes, move markers.
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).
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 a paragraph
officecli add report.docx /body --from /body/p[1]
# Copy a table
officecli add report.docx /body --from /body/tbl[1] --index 0Based on OfficeCLI v1.0.64