Cmdlet
Get-OfficeWord
Opens an existing Word document.
Syntax
Get-OfficeWord
[[-Content] <ScriptBlock>]
[-Password <String>]
[-Path] <String>
[-ReadOnly]
[<CommonParameters>]#Parameter set:
All Parameter SetsDescription
Returns an OfficeIMO WordDocument for inspection, advanced operations, or optional DSL edits.
Examples
Load a document in read-only mode.
$doc = Get-OfficeWord -Path .\Report.docx -ReadOnlyLoads Report.docx and exposes the document object for querying.
Run the Word DSL against an existing document.
$doc = Get-OfficeWord -Path .\Report.docx { WordParagraph -Text 'Appended by DSL' }; $doc | Save-OfficeWordLoads the document, appends content through the DSL, and returns the open document for saving or further edits.
Parameters
- -Content ScriptBlock
- Optional DSL scriptblock to execute against the loaded document.
- -Password String
- Password used to open an encrypted document package.
- -Path String
- Path to the .docx. Accepts PS paths.
- -ReadOnly SwitchParameter
- Open in read-only mode.
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.