Hello,
Can you tell me, please, how to disable "Insert Row" when right click with the mouse (not the Insert Row control from the "Worksheet Menu Bar")? And if this is done, how can it be restored to Enabled?
Thank you,
Ciorbea
Hello,
Can you tell me, please, how to disable "Insert Row" when right click with the mouse (not the Insert Row control from the "Worksheet Menu Bar")? And if this is done, how can it be restored to Enabled?
Thank you,
Ciorbea
Place the next code in the code for your sheet. It will disable the right mouse click (will send an esc key after the right click)
[vba]Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
MsgBox ("u can not use this")
SendKeys "{ESC}"
End Sub[/vba]
Charlize
Another way to do the same :
[vba]Sub DisableShortcutMenu()
CommandBars("Cell").Enabled = False
End Sub[/vba]
To activate the menu again :
[vba]
Sub EnableShortcutMenu()
CommandBars("Cell").Enabled = True
End Sub
[/vba]
Charlize
Last edited by Charlize; 10-02-2006 at 04:03 AM.
Original post change to assign Control numbers instead of named option. Controls(5) versus Controls("Insert")
The following toggles the Insert option (on or off) for the Cell and Row right click menu based on the Row's current status.
[vba]
Option Explicit
Sub toggleInsertRow()
Dim insertState As Boolean
insertState = Not CommandBars("Cell").Controls(5).Enabled
CommandBars("Row").Controls(5).Enabled = insertState
CommandBars("Cell").Controls(5).Enabled = insertState
End Sub
[/vba]
You are great!
Thank you!