Excel Right-Click Context Menu On Userform Textbox

Right Click Menu On Userform Textbox

           Menu in sample is created as a popup commandbar (with class module).The menu can be activated from the MouseUp event of the textbox:
Private WithEvents TControl As MSForms.TextBox
Private Sub TControl_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   If Button = 2 And Shift = 0 Then
   End If
End Sub

These operations can be performed with the right click menu :
☑ Clear
Private Sub CreateBar()
    Set cmdBar = Application.CommandBars.Add(, msoBarPopup, 0, 1)
    Set cmdCopyButton = cmdBar.Controls.Add(, 19)
    Set cmdPasteButton = cmdBar.Controls.Add(, 22)
    Set cmdClearButton = cmdBar.Controls.Add(, 47)
End Sub

1 comment:

  1. Hi I add a Frame to Userform now it stop work. How to fix it?