Disabling clear contents option in menu

  • Thread starter Thread starter priya
  • Start date Start date
P

priya

in excel sheet can we disable the "clear contents" option which is show
in the right click menu of any cel
 
priya,

Another post asked a similar question. If you insert the code belo
into a module the first sub will disable ClearContents and the secon
sub will enable ClearContents.

I found the list of ID nos for commands at the following site:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;213552

Hope you find it useful

Regards

Seamus



Sub Disable_ClearContents()
Enable_Disable_Commands 3125, False 'CANNOT Clear Contents
End Sub

Sub Enable_ClearContents()
Enable_Disable_Commands 3125, True 'CAN Clear Contents
End Sub

Sub Enable_Disable_Commands(id As Integer, Enab As Boolean)
Dim myControls As CommandBarControls
Dim ctl As CommandBarControl
Set myControls = CommandBars.FindControls _
(Type:=msoControlButton, id:=id)
For Each ctl In myControls
ctl.Enabled = Enab
Next ctl
End Su
 
Back
Top