Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Const PopUpName As String = "MyPopupMenu"
Sub DeletePopupMenu()
CommandBars(PopUpName).Delete
End Sub
Sub CreatePopupMenu()
Dim cb As CommandBar, cbp As CommandBarPopup
DeletePopup
Set cb = CommandBars.Add(PopUpName, msoBarPopup, False, True)
With cb
With .Controls.Add(Type:=msoControlButton)
.OnAction = "MethodIWishToExecute"
.FaceId = 71
.Caption = "Menu Item 1"
.TooltipText = "Tooltip text for menu item 1"
End With
Set cbp = .Controls.Add(Type:=msoControlPopup)
With cbp
.BeginGroup = True
.Caption = "Sub Menu"
With .Controls.Add(Type:=msoControlButton)
.OnAction = "MethodIWishToExecute"
.FaceId = 71
.Caption = "Submenu Item 1"
.TooltipText = "Tooltip text for submenu item 1"
End With
End With
Set cbp = Nothing
End With
Set cb = Nothing
End Sub
Sub DisplayPopUpMenu()
Application.CommandBars(PopUpName).ShowPopup
End Sub
Sub MethodIWishToExecute()
MsgBox "Put your macro code here!"
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then 'if right mouse-button is clicked then...
DisplayPopUpMenu
End If