[Solved] VBA: how to show right click menu on a excel form

  • When I run an excel vba form, the right click menus dont show on text boxes. Is there a workaround using windows API to enable copy paste menu on right click event?

    I appreciate your help

  • Hi global3 -

    I'm not really up on the API's so can't help you there.

    You've probably already thought of this, but could you just use the keyboard shortcuts CTRL-C for Copy and CTRL-V for Paste to get the functionality?


  • Thanks for quick reply. Cntrl 'C/V' is a good option and works great. I was researching and found Popup Show (if I define Custom Menu). The only problem is that teh example provided with excel vba help (commandbars.add), I have to rename "Copy" to something else to add to custom menu and now it does not copy. I would appreciate I could get help in this feature/

  • Here is the code I am using to initialize then calling CopyAndPasteMenu from mouse down event on a text box

    Private Sub UserForm_Initialize()
    On Error GoTo errHandler
    Set copyAndPasteMenu = CommandBars.Add( _
    Name:="Custom", Position:=msoBarPopup, _

    Set xCut = copyAndPasteMenu.Controls.Add
    With xCut
    .FaceId = CommandBars("Standard").Controls("Cut").ID
    .Caption = "Cut"
    End With

    Set xcopy = copyAndPasteMenu.Controls.Add
    With xcopy
    .FaceId = CommandBars("Standard").Controls("Copy").ID
    .Caption = "Copy"
    End With

    Set xpaste = copyAndPasteMenu.Controls.Add
    With xpaste
    .FaceId = CommandBars("Standard").Controls("Paste").ID
    .Caption = "Paste"
    End With

    Exit Sub
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!