Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Clear-OfficeExcelComment

Aliases: ExcelCommentClear
Module
PSWriteOffice
Aliases
ExcelCommentClear
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Int32

Clears legacy worksheet comments (notes) that match a filter.

Syntax

Clear-OfficeExcelComment
[-Address <String>]
[-All]
[-Author <String>]
[-PassThru]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-TextContains <String>]
[<CommonParameters>]
#
Parameter set: Context
Clear-OfficeExcelComment
[-Address <String>]
[-All]
[-Author <String>]
[-PassThru]
[-Path] <String>
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-TextContains <String>]
[<CommonParameters>]
#
Parameter set: Path
Clear-OfficeExcelComment
[-Address <String>]
[-All]
[-Author <String>]
-Document <ExcelDocument>
[-PassThru]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-TextContains <String>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Clear comments containing review text.

$removed = Clear-OfficeExcelComment -Path .\Report.xlsx -Sheet Data -TextContains review -Confirm:$false -PassThru
Get-OfficeExcelCommentAudit -Path .\Report.xlsx -IncludeComments |
    Select-Object LegacyCommentCount, ThreadedCommentCount

Removes matching comments and saves the workbook.

Parameters

-Address String optional
A1 cell address to match.
-All SwitchParameter optional
Allow clearing all comments on the selected worksheet(s) when no filter is supplied.
-Author String optional
Comment author to match, ignoring case.
-PassThru SwitchParameter optional
Returns the number of comments cleared.
-Range String optional
A1 cell or range to match.
-Sheet String optional
Worksheet name to update. Defaults to the current DSL sheet or all workbook sheets.
-SheetIndex Int32 optional
Worksheet index (0-based) to update. Defaults to the current DSL sheet or all workbook sheets.
-TextContains String optional
Text fragment to match, ignoring case.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Workbook path to update.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to update outside the DSL context.

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.