Thread: pop up menu
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
don bowyer don bowyer is offline
external usenet poster
 
Posts: 1
Default pop up menu

I want to raise a custom pop up menu when I right click in
a user form text box . I have the code that tells me which
mouse button was pressed when in the TB so all I need is
the code for the pop up.
I have tried the following from the VBA help files......

Set copyAndPasteMenu = CommandBars.Add( _
Name:="Custom", Position:=msoBarPopup, _
Temporary:=True)
Set copy = copyAndPasteMenu.Controls.Add
With copy
.FaceId = CommandBars("Standard").Controls("Copy").Id
.Caption = "Copy the selection"
End With
Set paste = copyAndPasteMenu.Controls.Add
With paste
.FaceId = CommandBars("Standard").Controls("Paste").Id
.Caption = "Paste from the Clipboard"
End With
copyAndPasteMenu.ShowPopup 200, 200

.......which works fine and would do what I want, but it
only ever runs once. If I try running it a second time I
get an error associated with first line of code. If I
close the application and Excel then restart all, it works
again, but just the once.
I notice it has no provision to delete the named
command bars it might have previously created . Could this
be the problem??
Any help from those wiser than I would be greatly
appreciated.
Don Bowyer