Skip to content

word field add

zmworm edited this page Apr 9, 2026 · 51 revisions

Word: Field - add

Insert document fields (page numbers, dates, etc.).

Type: field (with fieldType property), also shorthand types: pagenum/pagenumber/numpages/date/author/title/subject/filename/time

Parent: /body/p[N] or /body

Properties

Property Default Description
fieldType / type - Field type: page/pagenum, numpages, date, author, title, subject, filename, time
instruction (required if no fieldType) Field code (e.g. " PAGE ", " NUMPAGES ", " DATE \\@ \"yyyy-MM-dd\" ")
text "1" Placeholder display text
font - Font family
size - Font size (pt)
bold - Bold
color - Font color (hex)
alignment - Paragraph alignment (when parent is /body)

Examples

# Insert page number field
officecli add report.docx /body/p[1] --type pagenum

# Insert page number with formatting
officecli add report.docx /body/p[1] --type pagenumber --prop font=Arial --prop size=10

# Insert total pages field
officecli add report.docx /body/p[1] --type numpages

# Insert date field
officecli add report.docx /body/p[1] --type date

# Insert date field with custom format
officecli add report.docx /body/p[1] --type field --prop instruction=" DATE \\@ \"yyyy-MM-dd\" " --prop text="2026-01-01"

# Insert author, title, subject fields
officecli add report.docx /body/p[1] --type field --prop fieldType=author
officecli add report.docx /body/p[1] --type field --prop fieldType=title
officecli add report.docx /body/p[1] --type field --prop fieldType=filename

# Insert field at body level (creates paragraph)
officecli add report.docx /body --type pagenum --prop alignment=center

# Custom field instruction
officecli add report.docx /body/p[1] --type field --prop instruction=" PAGE " --prop text="1" --prop bold=true --prop size=12

Based on OfficeCLI v1.0.40

Clone this wiki locally