Export (0) Print
Expand All
Expand Minimize

WorksheetBase.Comments Property

Gets a Microsoft.Office.Interop.Excel.Comments collection that represents all the comments for the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

public Comments Comments { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Comments
A Microsoft.Office.Interop.Excel.Comments collection that represents all the comments for the worksheet.

The following code example uses the Comments property to display the number of comments on the current worksheet before and after adding a comment to cell A1.

This example is for a document-level customization.

private void GetCommentsCount()
{
    MessageBox.Show("Before adding a comment, there are " + 
        this.Comments.Count + " comments in the worksheet.");

    this.Range["A1", missing].AddComment("This is a comment for cell" +
        " A1");

    MessageBox.Show("After adding a comment, there are " + 
        this.Comments.Count + " comments in the worksheet.");
}

Show:
© 2015 Microsoft