VB.net Excel Add-In Right Click menu doesn't appear when clicking a pivot

Hi. I used the following code to build a rigt click menu. It works when I right click on the
Sheet but not when I click on the pivot


   Dim cBut As CommandBarButton

        Try
            Application.CommandBars("Cell").Controls("My Macro").Delete()
        Catch ex As Exception
            'No message as error will occur if "My Macro" not there
        End Try

        Try

            cBut = Application.CommandBars("Cell").Controls.Add(Temporary:=True)

            With cBut

                .Caption = "My Macro"

                .Style = MsoButtonStyle.msoButtonCaption

                .OnAction = "My_Macro"

            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Rory ArchibaldConnect With a Mentor Commented:
Also, FYI, there are in fact 2 Cell menus - one for Normal view and the other for Page Break Preview view.
0
 
Rory ArchibaldCommented:
The standard Cell menu is not displayed if you right-click a pivot cell - you get the "PivotTable Context Menu" instead.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks Rory.
0
All Courses

From novice to tech pro — start learning today.