If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Disable right click

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-20-05, 17:47
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
Question Disable right click

How can I disable right click on an excel sheet? It should display message saying "Command not allowed .."

Thanks.

~BS
Reply With Quote
  #2 (permalink)  
Old 01-21-05, 08:12
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

Try pasting this in the in every worksheet VBA code module that you want it disabled.

Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)
    MsgBox "Command not allowed.", vbCritical, "Command Disabled"
    Cancel = True
End Sub

HTH

MTB
Reply With Quote
  #3 (permalink)  
Old 01-21-05, 08:20
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi again

Alterrnatively you could put the code in the ThisWorkbook code module
ie
Code:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Excel.Range, Cancel As Boolean)
    MsgBox "Command not allowed.", vbCritical, "Command Disabled"
    Cancel = True
End Sub
This will disable all sheets right click.

MTB
Reply With Quote
  #4 (permalink)  
Old 01-21-05, 12:53
bhavesh78 bhavesh78 is offline
Registered User
 
Join Date: Dec 2004
Posts: 78
Thumbs up

Thanks Mike. The code works.

~BS
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On