API Reference
Cmdlet
New-OfficeWord
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
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 SetsParameters
- AutoSave SwitchParameter
- Enable OfficeIMO AutoSave mode.
- Content ScriptBlock
- DSL scriptblock describing document content.
- NoSave SwitchParameter
- Skip saving after executing the DSL.
- Open SwitchParameter
- Open the document after saving.
- OutputPath String
- Destination path for the document.
- PassThru SwitchParameter
- Emit a FileInfo for chaining.
- Password String
- Password used to save the document as an encrypted package.
- PdfAllowSystemFontEmbedding SwitchParameter
- Allow the native Word PDF converter to embed installed system fonts used by the document.
- PdfFontFamily String
- Optional default font family used by the native Word PDF converter.
- PdfPath String
- Optional PDF path to create from the same Word document before closing it.
- TemplatePath String
- Existing .docx file to clone before running the DSL.