Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

word reference

zmworm edited this page May 25, 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, 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

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]

Stable Element Addressing

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
  • paraId is assigned on creation and preserved across edits
  • textId refreshes when paragraph content changes (set, find-replace, add/remove run)
  • docPr IDs are auto-deduped on open
  • Get output now returns stable ID paths (e.g., p[@paraId=...] instead of p[N])

Tracked changes (revisions)

See Word: Revision for the full surface. Quick recap:

  • revision.type creates a revision (ins / del / format / moveFrom / moveTo)
  • revision.action acts on one (accept / reject) — typically via the /revision selector
  • Per-target accept/reject: set <doc> '/revision[@author=Alice][@type=ins]' --prop revision.action=accept
  • revisionNumber (renamed from revision in v1.0.98) is the per-save counter on docProps/core.xml, not a tracked edit.

Root containers

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.

Dotted-attr fallback (Tier-3 Set)

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=single

Values are validated for known enum / long-tail boolean attributes. Unknown attributes write through as raw XML.

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.64

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /