Wednesday, April 15, 2009

Macros in Excel : Disable Right Click Menu


Many times we need to disable right click menu in our workbook. We can achieve this by using Marcos in Excel. You need to add the Macro code to This workbook section in your VBA project. When you go to your Visual Basic Editor you can see the ThisWorkbook on the left hand side of your VBA Project.

You need to double click on highlighed portion and copy the following code. Since these macros has Private word before Sub, no one will be able to see this macros from View Macro menu.
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right click menu deactivated." & vbCrLf & _
"For this file:", 16, ""
End Sub

2 comments:

  1. Very techie blog on Excel and I have surprised to see so many thing on Excel , It's looks like a Programming in Excel rather than saying Tips on Excel.
    Yogesh - Great job done by you, Best wishes for your future.

    ReplyDelete
  2. Nice work Yogesh
    http://simulationandmodelingmadeeasy.blogspot.in/

    ReplyDelete