Creating a `PopUp Menu` using 'CommandBarPopup' what other methods are there? Context Menu.

rediffusion

Board Regular
Joined
Apr 24, 2019
Messages
60
I stumbled on this method add a `PopUp Menu` from Ron de Bruin (I olso write to him but no react). It describes how to add a "Menu" is there code to add for example "Gallery" (I'm more interested in the gallery), "ToggleButton" or "SplitButton" ?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I have a right click routine, where the options are shown as part of that menu
 
Upvote 0
Code:
Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Dim cBut As CommandBarButton
    Dim cBut2 As CommandBarButton
    Dim cBut3 As CommandBarButton

    On Error Resume Next

    With Application

        .CommandBars("Cell").Controls("Copy to CallSign").Delete
        .CommandBars("Cell").Controls("Copy to Personnel").Delete
        .CommandBars("Cell").Controls("Copy to Driving Hx").Delete

        Set cBut = .CommandBars("Cell").Controls.Add(Temporary:=True)
        Set cBut2 = .CommandBars("Cell").Controls.Add(Temporary:=True)
        Set cBut3 = .CommandBars("Cell").Controls.Add(Temporary:=True)

    End With

    With cBut2
        .Caption = "Copy to CallSign"
        .Style = msoButtonCaption
        .OnAction = "Copy2CallSign"
    End With

    With cBut
        .Caption = "Copy to Personnel"
        .Style = msoButtonCaption
        .OnAction = "Copy2Personnel"
    End With

    With cBut3
        .Caption = "Copy to Driving Hx"
        .Style = msoButtonCaption
        .OnAction = "Copy2DriverHx"        '*******************************
    End With



    On Error GoTo 0

End Sub
 
Upvote 0
it goes in the worksheet vba you want to use it on
 
Upvote 0
@mole999
user-offline.png

It works now! You show me example with "CommandBarButton"
Is it possible to use such:
"CommandBarGallery"
"CommandBarToggleButton"
"CommandBarSplitButton"
 
Upvote 0
I haven't played with command bars. If the vab is already written then just point the right click menu to the VBA
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top