Skip to content

word section set

zmworm edited this page Apr 30, 2026 · 52 revisions

Word: Section - set

Modify section page layout, orientation, and margins.

Path: /section[N] or /body/sectPr[N] (canonical form returned by get/query; both accepted on set)

Properties

Property Accepted Values Description
type continuous, evenPage/even, oddPage/odd, nextPage/next Break type. Invalid values throw an error.
pageWidth twips or units (cm, in, pt) Width (e.g., 21cm, 8.5in)
pageHeight twips or units (cm, in, pt) Height (e.g., 29.7cm, 11in)
orientation landscape, portrait Orientation. Setting landscape auto-swaps width/height if misaligned.
marginTop/Bottom/Left/Right twips Margins
columns/cols/col "3" or "3,720" Column count, or count with space (twips)
colWidths alternating values Custom column widths: "width,space,width,space,..." (twips)
separator/sep bool Line between columns
pageNumFmt full ECMA-376 enum Page-number numbering format. Accepts decimal, upperRoman, lowerRoman, upperLetter, lowerLetter, plus locale-aware values: hindiNumbers, hindiVowels, arabicAlpha, arabicAbjad, thaiLetters/thaiNumbers/thaiCounting, bahtText/dollarText, hebrew1/hebrew2, iroha, aiueo, ganada, chosung, chineseCounting/chineseLegalSimplified, japaneseCounting/japaneseDigitalTenThousand/japaneseLegal, koreanCounting/koreanLegal, decimalEnclosedCircle/Fullstop/Paren, decimalFullWidth/HalfWidth/Zero, vietnameseCounting, russianLower/russianUpper, etc. See i18n for the full list.
direction / dir rtl / ltr Section reading direction (<w:bidi/> on sectPr)
pageStart integer Restart page numbering at the given value
titlePage / titlePg bool Different first-page header/footer
break newPage/page (alias for nextPage) Section break alias
headerRef.default / headerRef.first / headerRef.even rId (read-only) Header reference targets surfaced on Get
footerRef.default / footerRef.first / footerRef.even rId (read-only) Footer reference targets surfaced on Get
rtlGutter bool RTL binding-gutter flag (<w:rtlGutter/>); ranks between bidi and docGrid in canonical schema order
pgBorders / pageBorders box, none Page-border shorthand. box emits a 4pt solid border on top/left/bottom/right in CT_PageBorders schema order; none strips the element

Note: Get returns pageWidth and pageHeight as unit-qualified cm strings (e.g., "21cm", "29.7cm").

Examples

# Set landscape with twips
officecli set report.docx /section[2] --prop orientation=landscape --prop pageWidth=15840 --prop pageHeight=12240

# Set A4 with unit suffixes
officecli set report.docx /section[1] --prop pageWidth=21cm --prop pageHeight=29.7cm

# Set US Letter with inches
officecli set report.docx /section[1] --prop pageWidth=8.5in --prop pageHeight=11in

# Set 3 equal columns
officecli set report.docx /section[1] --prop columns=3

# Set 3 columns with custom spacing (720 twips)
officecli set report.docx /section[1] --prop cols="3,720"

# Set custom column widths with spacing
officecli set report.docx /section[1] --prop colWidths="3000,720,2000,720,3000"

# Add separator line between columns
officecli set report.docx /section[1] --prop columns=2 --prop separator=true

Based on OfficeCLI v1.0.66

Clone this wiki locally