WorksheetBase.Comments 属性

获取一个表示工作表的所有注释的 Microsoft.Office.Interop.Excel.Comments 集合。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property Comments As Comments
public Comments Comments { get; }

属性值

类型:Microsoft.Office.Interop.Excel.Comments
一个表示工作表的所有注释的 Microsoft.Office.Interop.Excel.Comments 集合。

示例

下面的代码示例使用 Comments 属性在向单元格 A1 添加注释之前和之后显示当前工作表上的注释数。

此示例针对的是文档级自定义项。

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 安全性

请参见

参考

WorksheetBase 类

Microsoft.Office.Tools.Excel 命名空间