Cmdlet
Open-OfficeWord
Opens a Word document for explicit editing, or saves and closes a completed content block.
Syntax
Open-OfficeWord
[-AllowLoss]
[[-Content] <ScriptBlock>]
[-PassThru]
[-Password <SecureString>]
[-Path] <String>
[-ReadOnly]
[-Show]
[<CommonParameters>]#Parameter set:
PathOpen-OfficeWord
[-AllowLoss]
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-PassThru]
[-Password <SecureString>]
[-ReadOnly]
[-Show]
[<CommonParameters>]#Parameter set:
LiteralPathDescription
Opening preserves the document's theme and encryption. Without a block the document remains live. A failed block leaves the source unchanged; read-only input cannot run an authoring block.
Examples
Open a literal file path from a file pipeline.
$document = Get-Item './Review[final].docx' | Open-OfficeWord
$document | Close-OfficeWordEdit and save an existing document atomically.
Open-OfficeWord -Path ./Report.docx -PassThru {
WordParagraph 'Reviewed and approved'
}Parameters
- -AllowLoss SwitchParameter
- Gets or sets whether native-save loss is explicitly accepted.
- -Content ScriptBlock
- Gets or sets a content block; omission returns the live document.
- -PassThru SwitchParameter
- Gets or sets whether a completed content block returns the saved FileInfo.
- -Password SecureString
- Source password as a SecureString, credential, or warned plaintext value.
- -Path String
- Word document path with FileSystem wildcard expansion.
- -ReadOnly SwitchParameter
- Return a read-only live document. Cannot be combined with Content.
- -Show SwitchParameter
- Gets or sets whether the saved file opens in the system default application.
- -LiteralPath String
- Word document path without wildcard expansion; accepts FileInfo.FullName and provider PSPath.
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.