excel vba代码打开和关闭评论

时间:2016-03-19 00:25:36

标签: excel vba excel-vba

我正在寻找打开和关闭Excel评论的vba代码 - 我正在使用它们进行在线帮助。

Sub CommentsToggle_Click()
    If Help.Caption = "HELP" Then
    'If IsEmpty(Comments) = True Then
       Application.DisplayCommentIndicator = xlCommentAndIndicator
       Help.Caption = "HIDE COMMENTS"
    Else
       Application.DisplayCommentIndicator = xlCommentIndicatorOnly
      ' Comments = 1
    End If
 End Sub

1 个答案:

答案 0 :(得分:0)

您似乎正在使用切换按钮,在这种情况下,您必须在执行任何操作之前检查切换按钮的状态

Sub CommentsToggle_Click()
    If CommentsToggle.Value = True Then 'The toggle button is pressed
       Application.DisplayCommentIndicator = xlCommentAndIndicator
       Help.Caption = "HIDE COMMENTS"
    Else 'The toggle button is depressed :(
       Application.DisplayCommentIndicator = xlCommentIndicatorOnly
       Help.Caption = "HELP"
    End If
 End Sub