Skip to content

word document set

zmworm edited this page Apr 4, 2026 · 29 revisions

Word: Document - set

Set document-level metadata and page setup properties.

Path: /

Properties

Property Accepted Values Description
title text Document title
author / creator text Author name
subject text Subject
keywords text Keywords
description text Description
category text Category
lastModifiedBy text Last modifier
revision text Revision number
defaultFont font name Default document font
pageBackground / background hex color Page background
pageWidth integer (twips) Page width
pageHeight integer (twips) Page height
marginTop integer (twips) Top margin
marginBottom integer (twips) Bottom margin
marginLeft integer (twips) Left margin
marginRight integer (twips) Right margin

| protection | readOnly, comments, trackedChanges, forms, none | Document protection mode | | accept-changes | all | Accept all tracked changes | | reject-changes | all | Reject all tracked changes | | find | text or r"regex" | Search text or regex pattern (used with replace and/or format props) | | replace | text | Replacement text (optional; omit to format only) |

DocDefaults

Property Accepted Values Description
docDefaults.font font name Default font for all scripts
docDefaults.font.latin font name Default Latin/Ascii font
docDefaults.font.eastAsia font name Default East Asian font
docDefaults.font.cs font name Default Complex Script font
docDefaults.fontSize 12pt, 10.5pt Default font size
docDefaults.color hex color Default font color
docDefaults.bold true/false Default bold
docDefaults.italic true/false Default italic
docDefaults.alignment left, center, right, justify Default paragraph alignment
docDefaults.spaceBefore 6pt, 0.5cm Default space before
docDefaults.spaceAfter 6pt, 0.5cm Default space after
docDefaults.lineSpacing 1.5x, 150%, 18pt Default line spacing

DocGrid / CJK Layout

Property Accepted Values Description
docGrid.type default, lines, linesAndChars, snapToChars Grid type
docGrid.linePitch integer (twips) Grid line pitch
docGrid.charSpace integer Grid character spacing
autoSpaceDE true/false Auto-space East Asian / Latin
autoSpaceDN true/false Auto-space East Asian / numbers
kinsoku true/false Kinsoku line-breaking rules
overflowPunct true/false Overflow punctuation
charSpacingControl compressPunctuation, compressPunctuationAndJapaneseKana, doNotCompress Character spacing control

Compatibility

Property Accepted Values Description
compatibility.mode integer (e.g. 15) Compatibility mode version
compatibility.preset word2019, word2010, css-layout Apply preset compat flags
compatibility.<flag> true/false Individual compat flag (e.g. compatibility.useFarEastLayout)

Settings Flags

Property Accepted Values Description
embedFonts true/false Embed TrueType fonts
embedSystemFonts true/false Embed system fonts
saveSubsetFonts true/false Save font subsets only
mirrorMargins true/false Mirror margins for facing pages
gutterAtTop true/false Place gutter at top
bookFoldPrinting true/false Book fold printing
bookFoldReversePrinting true/false Reverse book fold
bookFoldPrintingSheets integer Sheets per booklet
evenAndOddHeaders true/false Different odd/even headers
defaultTabStop integer (twips) Default tab stop
displayBackgroundShape true/false Display background shape
doNotDisplayPageBoundaries true/false Hide page boundaries
removePersonalInfo true/false Remove personal info
removeDateAndTime true/false Remove date and time

Theme (all formats)

Property Accepted Values Description
theme.color.<slot> hex color Theme color (dk1, lt1, dk2, lt2, accent1-6, hlink, folHlink)
theme.font.major.latin font name Major (heading) Latin font
theme.font.major.eastAsia font name Major East Asian font
theme.font.minor.latin font name Minor (body) Latin font
theme.font.minor.eastAsia font name Minor East Asian font

Extended Properties (all formats)

Property Accepted Values Description
extended.template text Template name
extended.manager text Manager
extended.company text Company

Examples

officecli set report.docx / --prop title="Annual Report" --prop author="Finance Team"
officecli set report.docx / --prop pageWidth=12240 --prop pageHeight=15840
officecli set report.docx / --prop marginTop=1440 --prop marginBottom=1440
officecli set report.docx / --prop defaultFont="Times New Roman"

# Find and replace text (scope controlled by path)
officecli set report.docx / --prop find="2024" --prop replace="2025"
officecli set report.docx '/header[1]' --prop find="Draft" --prop replace="Final"

# Find and format (apply formatting to matched text without replacing)
officecli set report.docx / --prop find="IMPORTANT" --prop bold=true --prop color=FF0000
officecli set report.docx '/body/p[1]' --prop find="天气" --prop highlight=yellow

# Find with regex (r"..." prefix)
officecli set report.docx / --prop 'find=r"\d+%"' --prop color=red
officecli set report.docx / --prop 'find=r"\d{4}年\d{1,2}月"' --prop bold=true

# Find + replace + format (replace and style the replacement)
officecli set report.docx / --prop find="TODO" --prop replace="DONE" --prop bold=true --prop color=00AA00

# Protect document (only form fields editable)
officecli set report.docx / --prop protection=forms

# Remove protection
officecli set report.docx / --prop protection=none

Note: Batch set via selector path is also supported: officecli set doc.docx 'paragraph[style=Heading1]' --prop font=Arial

See also: Form Field for creating and filling text/checkbox/dropdown form fields.


Based on OfficeCLI v1.0.33

Clone this wiki locally