Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Add-OfficeWordSection

Aliases: WordSection
Module
PSWriteOffice
Aliases
WordSection
Inputs
OfficeIMO.Word.WordDocument
Outputs
OfficeIMO.Word.WordSection

Adds or reuses a section inside the current Word document.

Syntax

Add-OfficeWordSection
[-BreakType <NextPage|NextColumn|Continuous|EvenPage|OddPage>]
[[-Content] <ScriptBlock>]
[-PassThru]
[<CommonParameters>]
#
Parameter set: Context
Add-OfficeWordSection
[-BreakType <NextPage|NextColumn|Continuous|EvenPage|OddPage>]
[[-Content] <ScriptBlock>]
-Document <WordDocument>
[-PassThru]
[<CommonParameters>]
#
Parameter set: Document

Description

Provides the DSL entry point for section-level operations inside New-OfficeWord.

Examples

Create a section with a paragraph.

New-OfficeWord -Path .\doc.docx { Add-OfficeWordSection { Add-OfficeWordParagraph -Text 'Hello' } }

Creates a document and inserts a section that contains a single paragraph.

Add a section to a live document.

$section = $document | Add-OfficeWordSection -BreakType NextPage -PassThru
$section | Add-OfficeWordParagraph -Text 'Appendix' -Style Heading1

Adds a section through the document pipeline and uses the returned section as the next explicit target.

Parameters

-BreakType WordSectionBreakType optional
Optional section break type.
Possible values: NextPage, NextColumn, Continuous, EvenPage, OddPage
-Content ScriptBlock optionalposition: 0
DSL scriptblock executed within the section scope.
-PassThru SwitchParameter optional
Emit the created WordSection.
-Document WordDocument requiredpipeline: True (ByValue)sets: Document
Document that will receive a new section.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.