hiding right-click menu items in office programs... (1 Viewer)

accessuser1023

Registered User.
Local time
Today, 00:50
Joined
Nov 12, 2012
Messages
71
all,

In excel I'm trying to figure out how to eliminate (or hide) right-click items as they appear when you right-click a cell (or even on the worksheet itself). I believe the following folder (and key addition) in the registry is relevant to this request:

CURRENT USER \ SOFTWARE \ MICROSOFT \ OFFICE \ X.0 \ COMMON \ PERSONAMENU \ (new key needed) \ (value set to '0')

does this sound familiar to anyone? I'm pretty sure there is a folder somewhere in the registry around this area that is relevant to common events that happen in all office programs. But the problem in this scenario of mine of course, is that right-click menu items are going to be different in excel than they are in other office programs. None-the-less though, can they all be manipulated from this location in the registry by naming keys correctly and setting their values appropriately?

thanks!
 

Rx_

Nothing In Moderation
Local time
Yesterday, 23:50
Joined
Oct 22, 2009
Messages
2,803
Don't know about altering the registry key.
In Excel modules, you can do this:

Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Please Don't Right-Click again", VBOKOnly, "Special Message Just for You"
End Sub

Or maybe run this when Excel first opens:
Code:
Sub Disable_Shortcuts()
CommandBars(21).Enabled = False
End Sub

Also found this. Looks to me as if it would work. Has more control over the right-click.
If someone tries this and it works, please comment for the rest of us.
Code:
-- Place the following VBA in the "ThisWorkbook" area --

Private Sub Workbook_Open()

Run "DisableCut"
Run "Find_Disable_Commands"

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Run "EnableCut"
Run "Find_Enable_Commands"

End Sub

-- Place the following VBA in a new Module --

Sub DisableCut()
On Error Resume Next
With Application
'disables shortcut keys
.OnKey "^x", ""
'Disables Cut
.CommandBars("Standard").FindControl(ID:=21).Enabled = False
.CommandBars("Edit").FindControl(ID:=21).Enabled = False
.CommandBars("Cell").FindControl(ID:=21).Enabled = False
.CommandBars("Column").FindControl(ID:=21).Enabled = False
.CommandBars("Row").FindControl(ID:=21).Enabled = False
.CommandBars("Button").FindControl(ID:=21).Enabled = False
.CommandBars("XLM Cell").FindControl(ID:=21).Enabled = False
.CommandBars("Formula Bar").FindControl(ID:=21).Enabled = False
.CommandBars("Query").FindControl(ID:=21).Enabled = False
.CommandBars("Query Layout").FindControl(ID:=21).Enabled = False
.CommandBars("Object/Plot").FindControl(ID:=21).Enabled = False
.CommandBars("Phonetic Information").FindControl(ID:=21).Enabled = False
.CommandBars("Shapes").FindControl(ID:=21).Enabled = False
.CommandBars("Inactive Chart").FindControl(ID:=21).Enabled = False
.CommandBars("ActiveX Control").FindControl(ID:=21).Enabled = False
.CommandBars("OLE Object").FindControl(ID:=21).Enabled = False
.CommandBars("Excel Control").FindControl(ID:=21).Enabled = False
.CommandBars("WordArt Contex Menu").FindControl(ID:=21).Enabled = False
.CommandBars("Curve").FindControl(ID:=21).Enabled = False
.CommandBars("Pictures Contex Menu").FindControl(ID:=21).Enabled = False
.CommandBars("Rotate Mode").FindControl(ID:=21).Enabled = False
.CommandBars("Connector").FindControl(ID:=21).Enabled = False
.CommandBars("Script Anchor Popup").FindControl(ID:=21).Enabled = False
.CommandBars("Worksheet Menu Bar").FindControl(ID:=21).Enabled = False
End With
End Sub

Sub EnableCut()
On Error Resume Next
With Application
'enables shortcut keys
.OnKey "^x"
'Enables Cut
.CommandBars("Standard").FindControl(ID:=21).Enabled = True
.CommandBars("Edit").FindControl(ID:=21).Enabled = True
.CommandBars("Cell").FindControl(ID:=21).Enabled = True
.CommandBars("Column").FindControl(ID:=21).Enabled = True
.CommandBars("Row").FindControl(ID:=21).Enabled = True
.CommandBars("Button").FindControl(ID:=21).Enabled = True
.CommandBars("XLM Cell").FindControl(ID:=21).Enabled = True
.CommandBars("Formula Bar").FindControl(ID:=21).Enabled = True
.CommandBars("Query").FindControl(ID:=21).Enabled = True
.CommandBars("Query Layout").FindControl(ID:=21).Enabled = True
.CommandBars("Object/Plot").FindControl(ID:=21).Enabled = True
.CommandBars("Phonetic Information").FindControl(ID:=21).Enabled = True
.CommandBars("Shapes").FindControl(ID:=21).Enabled = True
.CommandBars("Inactive Chart").FindControl(ID:=21).Enabled = True
.CommandBars("ActiveX Control").FindControl(ID:=21).Enabled = True
.CommandBars("OLE Object").FindControl(ID:=21).Enabled = True
.CommandBars("Excel Control").FindControl(ID:=21).Enabled = True
.CommandBars("WordArt Contex Menu").FindControl(ID:=21).Enabled = True
.CommandBars("Curve").FindControl(ID:=21).Enabled = True
.CommandBars("Pictures Contex Menu").FindControl(ID:=21).Enabled = True
.CommandBars("Rotate Mode").FindControl(ID:=21).Enabled = True
.CommandBars("Connector").FindControl(ID:=21).Enabled = True
.CommandBars("Script Anchor Popup").FindControl(ID:=21).Enabled = True
.CommandBars("Worksheet Menu Bar").FindControl(ID:=21).Enabled = True
End With
End Sub

Sub Find_Disable_Commands()
Dim myControls As CommandBarControls
Dim ctl As CommandBarControl
Set myControls = CommandBars.FindControls _
(Type:=msoControlButton, ID:=21) '21 = cut
For Each ctl In myControls
ctl.Enabled = False
Next ctl
End Sub

Sub Find_Enable_Commands()
Dim myControls As CommandBarControls
Dim ctl As CommandBarControl
Set myControls = CommandBars.FindControls _
(Type:=msoControlButton, ID:=21) '21 = cut
For Each ctl In myControls
ctl.Enabled = True
Next ctl
End Sub

'Save the file then re-start Excel and the "CUT" should be disabled.
 

accessuser1023

Registered User.
Local time
Today, 00:50
Joined
Nov 12, 2012
Messages
71
thank you Rx. I will research what you've posted.
 

Users who are viewing this thread

Top Bottom