更新: 2008 年 7 月
| 适用于 | 
|---|
| 本主题中的信息仅适用于指定的 Visual Studio Tools for Office 项目和 Microsoft Office 版本。 项目类型 
 Microsoft Office 版本 
 有关更多信息,请参见按应用程序和项目类型提供的功能。 | 
可以通过编程方式显示和隐藏 Microsoft Office Excel 工作表中的注释。
在文档级自定义项中显示工作表中的所有注释
- 如果希望显示注释,请将 Visible 属性设置为 true,否则设置为 false。此代码必须放置在一个表类中,而不是放在 ThisWorkbook 类中。 - Private Sub ShowOrHideComments(ByVal show As Boolean) Dim i As Integer For i = 1 To Me.Comments.Count Me.Comments(i).Visible = show Next End Sub- private void ShowOrHideComments(bool show) { for (int i = 1; i <= this.Comments.Count; i++) { this.Comments[i].Visible = show; } }
在应用程序级外接程序中显示工作表中的所有注释
- 如果希望显示注释,请将 Visible 属性设置为 true,否则设置为 false。 - Private Sub ShowOrHideComments(ByVal show As Boolean) Dim worksheet As Excel.Worksheet = CType(Application.ActiveSheet, Excel.Worksheet) Dim i As Integer For i = 1 To worksheet.Comments.Count worksheet.Comments(i).Visible = show Next End Sub- private void ShowOrHideComments(bool show) { Excel.Worksheet worksheet = (Excel.Worksheet)Application.ActiveSheet; for (int i = 1; i <= worksheet.Comments.Count; i++) { worksheet.Comments[i].Visible = show; } }
请参见
任务
概念
修订记录
| 日期 | 修订历史记录 | 原因 | 
|---|---|---|
| 2008 年 7 月 | 增加了一个可在应用程序级外接程序中使用的代码示例。 | 客户反馈。 |