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
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?
.....Ralph
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, _
temporary:=True)
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
errHandler:
CommandBars("Custom").Delete
Resume
End Sub
have a look @ this Workbook Example from this link.
That is really great. Thanks a bunch. Two thumbs up Ivan.
Don’t have an account yet? Register yourself now and be a part of our community!