Reputation: 39
is there an easy way to enable the right click pop up menu in a text box in a user form in vba, excel? Im just trying to paste into a textbox but cant open the menu on right click in a user form
my code is giving a "Compile error: Argument not optional" and highlighting the .Add in the With Controls.Add ...
Private myMenu
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If (Button = 2) Then myMenu.ShowPopup
End Sub
Private Sub UserForm_Initialize()
With UserForm1
.StartUpPosition = 2
End With
Set myMenu = Application.CommandBars.Add(Position:=msoBarPopup, Temporary:=True)
With myMenu
With Controls.Add
.Caption = "Hello"
.OnAction = "HelloWorld"
End With
End With
End Sub
Upvotes: 2
Views: 2143