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)

Syntax

'Declaration
Public ReadOnly Property Comments As Comments
    Get
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.

Examples

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 Sub GetCommentsCount()
    MsgBox("Before adding a comment, there are " & _
        Me.Comments.Count & " comments in the worksheet.")

    Me.Range("A1").AddComment( _
        ("This is a comment for cell" & " A1"))

    MsgBox("After adding a comment, there are " & _
        Me.Comments.Count & " comments in the worksheet.")
End Sub
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.");
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace