Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Update-OfficeWordText

Aliases: Replace-OfficeWordText
Namespace PSWriteOffice
Aliases
Replace-OfficeWordText
Inputs
OfficeIMO.Word.WordDocument
Outputs
System.Int32

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

Authored help example

Replace text in an open document.

PS>


$count = $doc | Update-OfficeWordText -OldValue 'FY24' -NewValue 'FY25' -PassThru
        

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> [-PassThru] [<CommonParameters>]
#
Parameter set: Auto

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
IncludeHyperlinkAnchor SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink anchors.
IncludeHyperlinkText SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink display text.
IncludeHyperlinkTooltip SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink tooltips.
IncludeHyperlinkUri SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink URIs.
NewValue String requiredposition: namedpipeline: False
Replacement text.
OldValue String requiredposition: namedpipeline: False
Text to find.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.

Outputs

System.Int32

Update-OfficeWordText [-CaseSensitive] [-Document <WordDocument>] [-IncludeHyperlinkAnchor] [-IncludeHyperlinkText] [-IncludeHyperlinkTooltip] [-IncludeHyperlinkUri] -NewValue <String> -OldValue <String> [-PassThru] [<CommonParameters>]
#
Parameter set: Document

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
Document WordDocument optionalposition: namedpipeline: True (ByValue)
Document to update.
IncludeHyperlinkAnchor SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink anchors.
IncludeHyperlinkText SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink display text.
IncludeHyperlinkTooltip SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink tooltips.
IncludeHyperlinkUri SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink URIs.
NewValue String requiredposition: namedpipeline: False
Replacement text.
OldValue String requiredposition: namedpipeline: False
Text to find.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.

Outputs

System.Int32

Update-OfficeWordText [-CaseSensitive] [-IncludeHyperlinkAnchor] [-IncludeHyperlinkText] [-IncludeHyperlinkTooltip] [-IncludeHyperlinkUri] -NewValue <String> -OldValue <String> [-Open] [-PassThru] -Path <String> [<CommonParameters>]
#
Parameter set: Path

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
IncludeHyperlinkAnchor SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink anchors.
IncludeHyperlinkText SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink display text.
IncludeHyperlinkTooltip SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink tooltips.
IncludeHyperlinkUri SwitchParameter optionalposition: namedpipeline: False
Also replace hyperlink URIs.
NewValue String requiredposition: namedpipeline: False
Replacement text.
OldValue String requiredposition: namedpipeline: False
Text to find.
Open SwitchParameter optionalposition: namedpipeline: Falsealiases: Show
Open the file after saving when using -Path.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.
Path String requiredposition: 0pipeline: Falsealiases: FilePath, InputPath
Path to the .docx file to update in place.

Outputs

System.Int32