Share via


NamedRange.Comment 屬性

取得 Comment,表示與 NamedRange 控制項左上角儲存格關聯的註解。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
ReadOnly Property Comment As Comment
Comment Comment { get; }

屬性值

型別:Microsoft.Office.Interop.Excel.Comment
Comment 表示與 NamedRange 控制項左上角儲存格關聯的註解。

範例

下列程式碼範例會建立 NamedRange 並將註解加入至儲存格。 範例接著顯示訊息方塊,如果使用者按一下 [確定],則會使註解成為可見。

這是示範文件層級自訂的範例。

Private commentRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub AddCommentToRange()
    commentRange = Me.Controls.AddNamedRange( _
        Me.Range("C3"), "setColumnRowRange")
    Me.commentRange.AddComment("This is a comment.")
    Dim comment1 As Excel.Comment = Me.commentRange.Comment
    comment1.Visible = False
    If MessageBox.Show("Display comment?", "Comment Test", _
        MessageBoxButtons.OKCancel) = DialogResult.OK Then
        comment1.Visible = True
    End If
End Sub
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;
    }
}

.NET Framework 安全性

請參閱

參考

NamedRange 介面

Microsoft.Office.Tools.Excel 命名空間