API Reference

Cmdlet

New-OfficeWord

Aliases: WordNew

Creates a Word document using the DSL.

Remarks

Handles file creation or template cloning, scriptblock execution, optional autosave, and emits the document path when -PassThru is used.

Examples

Authored help example

Example 1: Create a document inline.

PS>


New-OfficeWord -Path .\Report.docx { WordSection { WordParagraph 'Hello DSL' } } -Open
        

Builds a document, adds one paragraph, saves it to disk, and opens it.

Example 2: Create a document from a template.

PS>


New-OfficeWord -TemplatePath .\Template.docx -Path .\Report.docx { WordParagraph -Text 'Generated content' -StyleId 'ReportBody' }
        

Copies the template to the output path, runs the DSL against the copied document, and saves it.

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.

Syntax

New-OfficeWord [-AutoSave] [-Content <ScriptBlock>] [-NoSave] [-Open] -OutputPath <String> [-PassThru] [-Password <String>] [-PdfAllowSystemFontEmbedding] [-PdfFontFamily <String>] [-PdfPath <String>] [-TemplatePath <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

AutoSave SwitchParameter optionalposition: namedpipeline: False
Enable OfficeIMO AutoSave mode.
Content ScriptBlock optionalposition: 1pipeline: False
DSL scriptblock describing document content.
NoSave SwitchParameter optionalposition: namedpipeline: False
Skip saving after executing the DSL.
Open SwitchParameter optionalposition: namedpipeline: False
Open the document after saving.
OutputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Destination path for the document.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit a FileInfo for chaining.
Password String optionalposition: namedpipeline: False
Password used to save the document as an encrypted package.
PdfAllowSystemFontEmbedding SwitchParameter optionalposition: namedpipeline: Falsealiases: AllowSystemFontEmbedding
Allow the native Word PDF converter to embed installed system fonts used by the document.
PdfFontFamily String optionalposition: namedpipeline: False
Optional default font family used by the native Word PDF converter.
PdfPath String optionalposition: namedpipeline: False
Optional PDF path to create from the same Word document before closing it.
TemplatePath String optionalposition: namedpipeline: False
Existing .docx file to clone before running the DSL.