Cmdlet
New-OfficeWord
Creates a themed Word document, returning a live document or saving a completed content block.
Syntax
New-OfficeWord
[-Force]
[[-Path] <String>]
[-Template <String>]
[-Theme <OfficeThemeInput>]
[<CommonParameters>]#Parameter set:
LiveNew-OfficeWord
[-AllowLoss]
[-Content] <ScriptBlock>
[-Force]
[-PassThru]
[-Password <SecureString>]
[-Path] <String>
[-Show]
[-Template <String>]
[-Theme <OfficeThemeInput>]
[<CommonParameters>]#Parameter set:
ContentDescription
Without a block no file is written, including on disposal. A block saves atomically; an existing destination requires Force. Template copies content, while Theme reads only the source theme.
Examples
Create and save a report.
New-OfficeWord -Path ./Report.docx -Theme Modern -PassThru {
WordHeading 'Service review'
WordParagraph 'All services are available.'
}Create a live document for explicit editing and saving.
$document = New-OfficeWord -Theme Boardroom
$document | Add-OfficeWordParagraph -Text 'Reviewed and approved'
Save-OfficeWord -Document $document -Path ./Review.docx
Close-OfficeWord -Document $documentParameters
- -Force SwitchParameter
- Allow a completed content block to replace an existing destination.
- -Path String
- Optional associated destination for a live document; required when a content block saves a file.
- -Template String
- Existing Word package copied as starting content. Its styling is preserved unless Theme is supplied.
- -Theme OfficeThemeInput
- Built-in theme, theme object or a document/template whose visual theme is read.
- -AllowLoss SwitchParameter
- Explicitly accept reductions reported by the content block's native save.
- -Content ScriptBlock
- Authoring block to complete before the document is atomically saved and closed.
- -PassThru SwitchParameter
- Return the saved FileInfo after a completed content block.
- -Password SecureString
- Password for a completed content block's saved file; use Save-OfficeWord for a live document.
- -Show SwitchParameter
- Open the saved result in its registered application after the content block succeeds.
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.