PDA

View Full Version : After RightClick, stop menu appearing



captHedge
03-12-2008, 03:49 AM
Hi All,

I have a little bit of code that shows a userform as part of the BeforeRightClick event.

Once I have finished with the userform and hide it, is there a way to stop the Right-Click menu showing ?

Thanks
captHedge

Bob Phillips
03-12-2008, 03:53 AM
Create a public variable and set it to false on closing the form, and test it in the event code.

BreakfastGuy
03-12-2008, 04:16 AM
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
MsgBox "No Right-Clicking!", vbOKOnly + vbInformation, "My Excel Events"
Cancel = True
End Sub
you can put the two lines (msgbox optional) at the end of the code in the module!

captHedge
03-12-2008, 04:18 AM
Thanks for that...

In the end, all I did was add this to the event

cancel = TRUE

before I called the userform and viola, the standard menu was cancelled at the end.

Thanks again