Hi ,
I have the following code for a pop up.
How do i get the option selected by the user??
For example, If user selects My Special Menu --> Button 1 then i sholud store this path to a variable..
Please help
I have the following code for a pop up.
Code:
Option Explicit
Public Const Mname As String = "MyPopUpMenu"
Sub DeletePopUpMenu()
'Delete PopUp menu if it exist
On Error Resume Next
Application.CommandBars(Mname).Delete
On Error GoTo 0
End Sub
Code:
'RUN THIS
Sub CreateDisplayPopUpMenu()
'Delete PopUp menu if it exist
Call DeletePopUpMenu
'Create the PopUpmenu
Call Custom_PopUpMenu_1
'Show the PopUp menu
On Error Resume Next
Application.CommandBars(Mname).ShowPopup
On Error GoTo 0
End Sub
Code:
Sub Custom_PopUpMenu_1()
Dim MenuItem As CommandBarPopup
'Add PopUp menu
With Application.CommandBars.Add(Name:=Mname, Position:=msoBarPopup, _
MenuBar:=False, Temporary:=True)
' Add menu with two buttons
Set MenuItem = .Controls.Add(Type:=msoControlPopup)
With MenuItem
.Caption = "My Special Menu"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Button 1 in menu"
.FaceId = 71
.OnAction = "'" & ThisWorkbook.Name & "'!" & "TestMacro"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Button 2 in menu"
.FaceId = 72
.OnAction = "'" & ThisWorkbook.Name & "'!" & "TestMacro"
End With
End With
End With
End Sub
Sub TestMacro()
MsgBox "Hi"
End Sub
How do i get the option selected by the user??
For example, If user selects My Special Menu --> Button 1 then i sholud store this path to a variable..
Please help