Expand Minimize

NamedRange.Comment Property

Gets a Comment that represents the comment associated with the cell in the upper left corner of the NamedRange control.

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

Comment Comment { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Comment
A Comment that represents the comment associated with the cell in the upper left corner of the NamedRange control.

The following code example creates a NamedRange and adds a comment to the cell. It then displays a message box that causes the comment to become visible if the user clicks OK.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange commentRange;
private void AddCommentToRange()
{
    commentRange = this.Controls.AddNamedRange(
        this.Range["C3"], "setColumnRowRange");
    this.commentRange.AddComment("This is a comment.");
    Excel.Comment comment1 = this.commentRange.Comment;
    comment1.Visible = false;
    if (MessageBox.Show("Display comment?", "Comment Test",
        MessageBoxButtons.OKCancel) == DialogResult.OK)
    {
        comment1.Visible = true;
    }
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft