-
Notifications
You must be signed in to change notification settings - Fork 528
word field add
zmworm edited this page May 1, 2026
·
51 revisions
Insert document fields (page numbers, dates, mail merge, cross-references, etc.).
Type: field (with fieldType property), or shorthand type names directly
Parent: /body/p[N] or /body
| Property | Default | Description |
|---|---|---|
fieldType / type
|
- | Field type (see tables below) |
instruction / instr
|
(required if no fieldType) | Raw field code (e.g. " PAGE ", " MERGEFIELD Name "). Get returns the canonical short key instr; instruction is accepted as input alias. |
text |
type-dependent | Placeholder display text (defaults vary by type) |
font |
- | Font family |
size |
- | Font size (pt) |
bold |
- | Bold |
color |
- | Font color (hex) |
alignment |
- | Paragraph alignment (when parent is /body) |
These types require no additional properties:
| Type | Field Code | Description |
|---|---|---|
pagenum / pagenumber / page
|
PAGE |
Current page number |
numpages |
NUMPAGES |
Total page count |
sectionpages |
SECTIONPAGES |
Pages in current section |
section |
SECTION |
Current section number |
date |
DATE \@ "yyyy-MM-dd" |
Current date |
createdate |
CREATEDATE \@ "yyyy-MM-dd" |
Document creation date |
savedate |
SAVEDATE \@ "yyyy-MM-dd" |
Last save date |
printdate |
PRINTDATE \@ "yyyy-MM-dd" |
Last print date |
edittime |
EDITTIME |
Total editing time (minutes) |
time |
TIME |
Current time |
author |
AUTHOR |
Author name |
lastsavedby |
LASTSAVEDBY |
Last saved by |
title |
TITLE |
Document title |
subject |
SUBJECT |
Document subject |
filename |
FILENAME |
File name |
numwords |
NUMWORDS |
Word count |
numchars |
NUMCHARS |
Character count |
revnum |
REVNUM |
Revision number |
template |
TEMPLATE |
Template name |
comments / doccomments
|
COMMENTS |
Document comments property |
keywords |
KEYWORDS |
Document keywords |
officecli add report.docx /body/p[1] --type pagenum officecli add report.docx /body/p[1] --type numpages officecli add report.docx /body/p[1] --type date officecli add report.docx /body/p[1] --type author officecli add report.docx /body/p[1] --type filename officecli add report.docx /body/p[1] --type numwords
| Property | Required | Description |
|---|---|---|
fieldName / name
|
yes | Merge field name |
Display text defaults to «FieldName».
officecli add report.docx /body/p[1] --type mergefield --prop fieldName=CustomerName
officecli add report.docx /body/p[1] --type mergefield --prop fieldName=InvoiceDate --prop text="[Date]"| Property | Required | Description |
|---|---|---|
bookmarkName / bookmark / name
|
yes | Target bookmark name |
hyperlink |
no |
true to add \h switch (clickable link) |
officecli add report.docx /body/p[1] --type ref --prop bookmarkName=MyBookmark --prop hyperlink=true officecli add report.docx /body/p[1] --type pageref --prop bookmarkName=AppendixA officecli add report.docx /body/p[1] --type noteref --prop bookmarkName=FootnoteRef1
| Property | Required | Description |
|---|---|---|
identifier / name / id
|
yes | Sequence name (e.g. Figure, Table, Equation) |
officecli add report.docx /body/p[1] --type seq --prop identifier=Figure officecli add report.docx /body/p[1] --type seq --prop identifier=Table
| Property | Required | Description |
|---|---|---|
styleName / name
|
yes | Style name to reference (e.g. "Heading 1") |
officecli add report.docx /body/p[1] --type styleref --prop styleName="Heading 1"| Property | Required | Description |
|---|---|---|
propertyName / name
|
yes | Property name (e.g. Department, ProjectCode) |
officecli add report.docx /body/p[1] --type docproperty --prop propertyName=Department
| Property | Required | Description |
|---|---|---|
expression / condition
|
yes | Condition expression (e.g. MERGEFIELD Gender = \"Male\") |
trueText |
no | Text when condition is true |
falseText |
no | Text when condition is false |
Display text defaults to the trueText value.
officecli add report.docx /body/p[1] --type if \ --prop expression="MERGEFIELD Gender = \"Male\"" \ --prop trueText=Mr. --prop falseText=Ms.
For any field type not listed above, use the instruction property directly:
officecli add report.docx /body/p[1] --type field --prop instruction=" PAGE " --prop text="1" --prop bold=true --prop size=12 officecli add report.docx /body/p[1] --type field --prop instruction=" TOC \\o \"1-3\" " --prop text="Table of Contents"
When the parent is /body, a new paragraph is created with the specified alignment:
officecli add report.docx /body --type pagenum --prop alignment=center
Based on OfficeCLI v1.0.64