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

command add word

zmworm edited this page Apr 29, 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
ole oleobject, embed, embeddedobject /body, /body/p[N] Word-OLE-Add

OLE / Embedded Object

Embed an Office (or other OLE-compatible) document as an object inside the Word document. The embedded source file is copied into the package; Word will render it either inline via an image preview or as a clickable icon.

Property Required Description
src yes Path to the file to embed (.docx, .xlsx, .pptx, .pdf, etc.). Alias: path.
progId no OLE ProgID (e.g. Word.Document.12, Excel.Sheet.12, Package). Auto-detected from src extension when omitted.
width no Display width as unit-qualified size (6cm, 2in, 160pt) or raw EMU.
height no Display height as unit-qualified size (4cm, 1.5in, 120pt) or raw EMU.
display no content (default, shows live preview) or icon (shows an icon + filename).
icon no Path to a custom icon image (only meaningful with display=icon).
name no Display name shown under the icon.

Examples

×ばつ 4cm officecli add doc.docx /body --type ole --prop src="deck.pptx" --prop --prop height="4cm" # Embed a PDF as an icon with a custom label officecli add doc.docx /body --type ole --prop src="report.pdf" --prop display=icon --prop name="Q3 Report"">
# Embed an Excel workbook inline at default size
officecli add doc.docx /body --type ole --prop src=sales.xlsx
# Embed a PowerPoint deck at 6cm ×ばつ 4cm
officecli add doc.docx /body --type ole --prop src=deck.pptx --prop width=6cm --prop height=4cm
# Embed a PDF as an icon with a custom label
officecli add doc.docx /body --type ole --prop src=report.pdf --prop display=icon --prop name="Q3 Report"

Position by DOM Path

Use --after or --before with a DOM path to insert relative to a sibling:

# Insert a paragraph after the 2nd paragraph
officecli add doc.docx /body --type paragraph --after /body/p[2] --prop text="Inserted"
# Insert a paragraph before the first table
officecli add doc.docx /body --type paragraph --before /body/tbl[1] --prop text="Table intro"

Text-Anchored 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 (run, image, hyperlink, bookmark, field) are inserted within the paragraph, adjacent to the matched text.
  • Block types (table, paragraph, section, break) cause the paragraph to split at the match point; the new block element is inserted between the resulting halves.
  • Add --prop regex=true for regex matching.

Examples

# Insert a run after the text "weather" in paragraph 1
officecli add doc.docx '/body/p[1]' --type run --after find:weather --prop "text= (sunny)"
# Insert a run before the text "weather"
officecli add doc.docx '/body/p[1]' --type run --before find:weather --prop "text=["
# Insert a table after a sentence (splits the paragraph)
officecli add doc.docx '/body/p[1]' --type table --after "find:first sentence." --prop rows=2 --prop cols=2
# Regex: insert after the first number sequence
officecli add doc.docx '/body/p[1]' --type run --after 'find:\d+' --prop regex=true --prop "text= (new high)"

See Also


Based on OfficeCLI v1.0.64

Clone this wiki locally

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