ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can't disable RIGHT CLICK (https://www.excelbanter.com/excel-programming/443181-cant-disable-right-click.html)

AP[_3_]

Can't disable RIGHT CLICK
 
I'm trying to disable right-clicking of all sheets except in the sheet
named "Home". I've put the following code, as recommended by VBE help,
in the "ThisWorkbook" object module:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, ByVal Cancel As Boolean)
If Sh.name < "Home" Then Cancel = True
End Sub

But I keep getting the following error when I open the workbook:

"Compile error: Procedure declaration does not match description of
event or procedure having the same name"

It's driving me nuts as I don't have another procedure with the same
name ! Any help would be greatly appreciated.

Peter T[_5_]

Can't disable RIGHT CLICK
 
It should be ByRef Cancel or simply Cancel, not ByVal. Always best to select
event stubs from the dropdown.

Regards,
Peter T

"AP" wrote in message
...
I'm trying to disable right-clicking of all sheets except in the sheet
named "Home". I've put the following code, as recommended by VBE help,
in the "ThisWorkbook" object module:

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
Target As Range, ByVal Cancel As Boolean)
If Sh.name < "Home" Then Cancel = True
End Sub

But I keep getting the following error when I open the workbook:

"Compile error: Procedure declaration does not match description of
event or procedure having the same name"

It's driving me nuts as I don't have another procedure with the same
name ! Any help would be greatly appreciated.




All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com