I'm trying to run the following code from an add-in, but for some reason the event never fires off. If I move it to the current workbook itself it is fine. So I assume it is some issue with Add-ins or is there another event I could use for an Add-in?
Code:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As
Object, ByVal Target As Range, Cancel As Boolean)
Dim CheckForText As Object
Dim CurrentShortcutMenu As CommandBar
Dim CurrentMenuItem1 As CommandBarControl, CurrentMenuItem2 As CommandBarControl
Set CurrentShortcutMenu = Application.CommandBars("Cell")
Set CheckForText = Selection.Comment
Set CurrentMenuItem1 = CurrentShortcutMenu.Controls.Item("Copy Comment")
Set CurrentMenuItem2 = CurrentShortcutMenu.Controls.Item("Paste Comment")
If Not CheckForText Is Nothing Then
CurrentMenuItem1.Visible = True
CurrentMenuItem2.Visible = True
ElseIf CheckForText Is Nothing Then
If CurrentMenuItem1.Visible <> False Then
CurrentMenuItem1.Visible = False
CurrentMenuItem2.Visible = False
End If
End If
End Sub