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-OfficeExcelText

Aliases: Replace-OfficeExcelText
Namespace PSWriteOffice
Aliases
Replace-OfficeExcelText
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Int32

Replaces text in worksheet values.

Remarks

Replaces text in worksheet values.

Examples

Authored help example

Replace status text and verify the update count.

PS>


$count = Update-OfficeExcelText -Path .\Report.xlsx -Sheet Summary -OldValue Draft -NewValue Ready -PassThru
            [pscustomobject]@{
                Path = '.\Report.xlsx'
                Replacements = $count
            }
        

Updates matching text cells on a sheet, saves the workbook, and returns the replacement count.

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-OfficeExcelText [-CaseSensitive] -NewValue <String> -OldValue <String> [-Open] [-PassThru] -Path <String> [-Range <String>] [-Regex] [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Path

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
NewValue String requiredposition: namedpipeline: False
Replacement text.
OldValue String requiredposition: namedpipeline: False
Text or pattern to replace.
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
Workbook path to update.
Range String optionalposition: namedpipeline: False
A1 range to update. Defaults to each selected worksheet's used range.
Regex SwitchParameter optionalposition: namedpipeline: False
Treat -OldValue as a regular expression.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name. Defaults to all sheets for path/document use and current sheet inside an ExcelSheet block.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index when using a workbook object or path.

Outputs

System.Int32

Update-OfficeExcelText [-CaseSensitive] -Document <ExcelDocument> -NewValue <String> -OldValue <String> [-PassThru] [-Range <String>] [-Regex] [-Sheet <String>] [-SheetIndex <Int32>] [<CommonParameters>]
#
Parameter set: Document

Parameters

CaseSensitive SwitchParameter optionalposition: namedpipeline: False
Use case-sensitive matching.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to update outside the DSL context.
NewValue String requiredposition: namedpipeline: False
Replacement text.
OldValue String requiredposition: namedpipeline: False
Text or pattern to replace.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit the object created or changed by the command.
Range String optionalposition: namedpipeline: False
A1 range to update. Defaults to each selected worksheet's used range.
Regex SwitchParameter optionalposition: namedpipeline: False
Treat -OldValue as a regular expression.
Sheet String optionalposition: namedpipeline: Falsealiases: WorksheetName
Worksheet name. Defaults to all sheets for path/document use and current sheet inside an ExcelSheet block.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index when using a workbook object or path.

Outputs

System.Int32