Skip to content

word header footer add

zmworm edited this page Apr 27, 2026 · 50 revisions

Word: Header/Footer - add

Add page headers and footers with text, fields, and formatting.

Parent: / (document root)

Properties

Property Default Description
text (empty) Static text content
field - Insert a document field (see field values below)
type default Header/footer variant: default, first, even
alignment - left, center, right, justify (alias: align)
font - Font family (sets Ascii, HighAnsi, and EastAsia)
size - Font size (accepts 14, 14pt, 10.5pt)
bold - Bold (true/false)
italic - Italic (true/false)
color - Text color (#FF0000, FF0000, red, rgb(255,0,0))

Both text and field can be specified together -- the static text appears first, followed by the field.

Field values

Value OOXML field Description
page, pagenum, pagenumber PAGE Current page number
numpages NUMPAGES Total page count
date DATE \@ "yyyy-MM-dd" Current date
time TIME Current time
author AUTHOR Document author
title TITLE Document title
filename FILENAME File name
(other) uppercased as-is Any OOXML field code

Fields are inserted as complex field sequences (fldChar Begin/Separate/End). Run properties from font, size, bold, italic, color are applied to all field runs.

Type behavior

Type Effect
default Added as the default header/footer for the last section
first Added as first-page variant; automatically enables <w:titlePage> on the section
even Added as even-page variant; requires evenAndOddHeaders=true on document settings

Examples

# Add a default header with centered bold text
officecli add report.docx / --type header \
  --prop text="Company Name" --prop alignment=center --prop bold=true

# Add a first-page header (titlePage is auto-enabled)
officecli add report.docx / --type header \
  --prop text="Title Page" --prop type=first

# Add a footer with page number
officecli add report.docx / --type footer \
  --prop field=page --prop alignment=center --prop size=9

# Add a footer with both text and page number
officecli add report.docx / --type footer \
  --prop text="Page " --prop field=page --prop alignment=right

# Add an even-page header (set evenAndOddHeaders first)
officecli set report.docx /settings --prop evenAndOddHeaders=true
officecli add report.docx / --type header \
  --prop text="Even Page" --prop type=even

# Add a footer with date field and custom font
officecli add report.docx / --type footer \
  --prop field=date --prop font="Arial" --prop size=8 --prop color=888888

Based on OfficeCLI v1.0.56

Clone this wiki locally