Share via


WorksheetBase.Comments Property

Definition

Gets a Comments collection that represents all the comments for the worksheet.

public:
 property Microsoft::Office::Interop::Excel::Comments ^ Comments { Microsoft::Office::Interop::Excel::Comments ^ get(); };
public Microsoft.Office.Interop.Excel.Comments Comments { get; }
member this.Comments : Microsoft.Office.Interop.Excel.Comments
Public ReadOnly Property Comments As Comments

Property Value

A 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 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.");
}
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

Applies to