API Reference
Update-OfficeWordText
Replaces text in a Word document.
Remarks
Supports direct document objects, file paths, and the active DSL document. Hyperlink labels and metadata can be updated when requested.
Examples
Replace text in an open document.
PS>
$doc | Update-OfficeWordText -OldValue 'FY24' -NewValue 'FY25'
Updates matching text in the loaded document and returns the number of replacements.
Replace hyperlink targets in a file.
PS>
Update-OfficeWordText -Path .\Report.docx -OldValue 'old.example.com' -NewValue 'new.example.com' -IncludeHyperlinkUri
Loads the document, updates matching hyperlink URLs, saves the file, and closes 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
Update-OfficeWordText [-CaseSensitive] [-IncludeHyperlinkAnchor] [-IncludeHyperlinkText] [-IncludeHyperlinkTooltip] [-IncludeHyperlinkUri] -NewValue <String> -OldValue <String> [<CommonParameters>]
#
AutoParameters
- CaseSensitive SwitchParameter
- Use case-sensitive matching.
- IncludeHyperlinkAnchor SwitchParameter
- Also replace hyperlink anchors.
- IncludeHyperlinkText SwitchParameter
- Also replace hyperlink display text.
- IncludeHyperlinkTooltip SwitchParameter
- Also replace hyperlink tooltips.
- IncludeHyperlinkUri SwitchParameter
- Also replace hyperlink URIs.
- NewValue String
- Replacement text.
- OldValue String
- Text to find.
Outputs
System.Int32
Update-OfficeWordText [-CaseSensitive] [-Document <WordDocument>] [-IncludeHyperlinkAnchor] [-IncludeHyperlinkText] [-IncludeHyperlinkTooltip] [-IncludeHyperlinkUri] -NewValue <String> -OldValue <String> [<CommonParameters>]
#
DocumentParameters
- CaseSensitive SwitchParameter
- Use case-sensitive matching.
- Document WordDocument
- Document to update.
- IncludeHyperlinkAnchor SwitchParameter
- Also replace hyperlink anchors.
- IncludeHyperlinkText SwitchParameter
- Also replace hyperlink display text.
- IncludeHyperlinkTooltip SwitchParameter
- Also replace hyperlink tooltips.
- IncludeHyperlinkUri SwitchParameter
- Also replace hyperlink URIs.
- NewValue String
- Replacement text.
- OldValue String
- Text to find.
Outputs
System.Int32
Update-OfficeWordText [-CaseSensitive] [-IncludeHyperlinkAnchor] [-IncludeHyperlinkText] [-IncludeHyperlinkTooltip] [-IncludeHyperlinkUri] -InputPath <String> -NewValue <String> -OldValue <String> [-Show] [<CommonParameters>]
#
PathParameters
- CaseSensitive SwitchParameter
- Use case-sensitive matching.
- IncludeHyperlinkAnchor SwitchParameter
- Also replace hyperlink anchors.
- IncludeHyperlinkText SwitchParameter
- Also replace hyperlink display text.
- IncludeHyperlinkTooltip SwitchParameter
- Also replace hyperlink tooltips.
- IncludeHyperlinkUri SwitchParameter
- Also replace hyperlink URIs.
- InputPath String
- Path to the .docx file to update in place.
- NewValue String
- Replacement text.
- OldValue String
- Text to find.
- Show SwitchParameter
- Open the file after saving when using -Path.
Outputs
System.Int32