Skip to content

command add word

zmworm edited this page Apr 4, 2026 · 53 revisions

add - Word (.docx)

Addable element types in Word documents.

Element Types

Type Aliases Parent Reference
paragraph p /body, headers, cells Word-Paragraph-Add
run r /body/p[N] Word-Run-Add
table tbl /body Word-Table-Add
row tr /body/tbl[N] Word-Table-Add
cell tc /body/tbl[N]/tr[M] Word-Table-Add
picture image, img /body, /body/p[N] Word-Picture-Add
chart - /body Word-Chart-Add
equation formula, math /body, /body/p[N] Word-Equation-Add
hyperlink link /body/p[N] Word-Hyperlink-Add
comment - /body/p[N] Word-Comment-Add
bookmark - /body/p[N] Word-Bookmark-Add
section sectionBreak /body Word-Section-Add
footnote - /body/p[N] Word-Footnote-Add
endnote - /body/p[N] Word-Footnote-Add
toc tableOfContents /body Word-TOC-Add
header - / Word-Header-Footer-Add
footer - / Word-Header-Footer-Add
watermark - / Word-Watermark-Add
style - /styles Word-Style-Add
field pagenum, pagenumber, numpages, date /body/p[N], /body Word-Field-Add
pagebreak/break columnbreak /body/p[N], /body Word-Break-Add
sdt contentcontrol /body, /body/p[N] Word-SDT-Add
formfield ff /body Word-FormField

Positional Insert with --after find:X / --before find:X

Insert elements at a text-matched position within a paragraph. Use --after find:X or --before find:X to locate the insertion point by matching text content.

  • Inline types (e.g. run) are inserted within the paragraph, adjacent to the matched text.
  • Block types (e.g. table, paragraph) cause the paragraph to split at the match point; the new element is inserted between the resulting halves.
  • Supports r"..." prefix for regex matching.

Examples

# Insert a run after the text "天气" in paragraph 1
officecli add doc.docx '/body/p[1]' --type run --after find:天气 --prop text=(晴)

# Insert a table after a sentence (splits the paragraph)
officecli add doc.docx '/body/p[1]' --type table --after find:第一句话。 --prop rows=2 --prop cols=2

See Also


Based on OfficeCLI v1.0.33

Clone this wiki locally