Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You can programmatically show and hide comments in Microsoft Office Excel worksheets.
Applies to: The information in this topic applies to document-level projects and application-level projects for Excel 2007 and Excel 2010. For more information, see Features Available by Office Application and Project Type.
To display all comments on a worksheet in a document-level customization
Set the Visible property to true if you want to show comments; otherwise false. This code must be placed in a sheet class, not in the ThisWorkbook class.
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; } }
To display all comments on a worksheet in an application-level add-in
Set the Visible property to true if you want to show comments; otherwise 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; } }
See Also
Tasks
How to: Add and Delete Worksheet Comments