Shortcut Menus

Const PopUpName As String "MyPopUpMenu" 

Sub DeletePopupMenu
End Sub

Sub CreatePopupMenu
Dim cb As CommandBar
Dim cbp As CommandBarPopup

   Set cb = CommandBars.Add(PopUpName, msoBarPopup, False, True)
   With cb
      With .Controls.Add(Type:=msoControlButton)
         .OnAction = ""
         .FaceId = 10
         .Caption = ""
         .ToolTipText = ""
       End With

      Set cbp = .Controls.Add(Type:=msoControlPopul
      With cbp
         .BeginGroup = True
          .Caption = "sub menu"
           With .Controls.Add(Type:=msoControlButton)

           End With
           Set cbp = Nothing
      End With
   End With
Set cb = Nothing
End Sub

Sub DisplayPopUp 
End Sub

In the Userform code module

Private Sub UserForm_MouseMove(byVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) 
   if Button = 2 Then
'number 2 is the right mouse button
      Call DisplayPopUp
   End If
End Sub

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext