disable mouse right click


Posted by Jim on December 11, 2001 5:37 PM

Hi group,
What is the code to disable the the menu on the mouse
right click.
Thanks, Jim

Posted by Juan Pablo G. on December 11, 2001 5:43 PM

This will disable it in all sheets. It goes in the workbook module.

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub

Juan Pablo G.

Posted by Jim on December 11, 2001 6:13 PM

What about disabling only 1 sheet in the book

Hi Juan,
I only nee it to be disabled on 1 (a particular sheet)
any thoughts?
Jim

Posted by Juan Pablo G. on December 11, 2001 6:33 PM

Re: What about disabling only 1 sheet in the book

Sure, paste this in the Sheet's module

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub

Or, in the same code that i sent put this.

If Sh.Name = "Sheet1" then Cancel = True

Juan Pablo G.

: This will disable it in all sheets. It goes in the workbook module. : Cancel = True : End Sub

Posted by Bariloche on December 11, 2001 6:33 PM

Re: What about disabling only 1 sheet in the book

Jim,

Same event, different place.

Right click on the sheet tab for the sheet in question. Click on view code. This opens the code sheet "behind" the worksheet. In the left hand drop-down list box, select "Worksheet". Then in the right hand drop-down list box select the event you want to trap. Excel will put in the Sub and End Sub stuff all you need to do is put in Cancel = True as Juan advised.


enjoy


Hi Juan,

: This will disable it in all sheets. It goes in the workbook module. : Cancel = True : End Sub



Posted by Jim on December 11, 2001 6:56 PM

Thanks guys, you were a big help

: I only nee it to be disabled on 1 (a particular sheet) : any thoughts? : Jim :