excel 2007 VBA disable CUT button

Ñ

Ñô¹â

How to disabled excel2007 CUT button?
--------------------------------
Private Sub Workbook_Open()
Application.OnKey "^x", ""
Application.OnKey "+{delete}", ""
Application.CommandBars("cell").Controls(1).Enabled = False
'Application.CellDragAndDrop = False
'How to disabled excel2007 CUT button?
End Sub
 
R

Ron de Bruin

Try

If you use Excel 2000-2003 you can use the code below that use the Office.CommandBarControl

Sub MenuControl_False()
' Excel 2000 - 2003
Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(ID:=21)
Ctrl.Enabled = False
Next Ctrl
End Sub

If you use Excel 97 then use this example (also working in 2000-2003)

Sub MenuControl_Enabled_False()
' Excel 97 - 2003
Dim Ctl As CommandBarControl
Dim Cbar As Integer

On Error Resume Next
For Cbar = 1 To Application.CommandBars.Count
For Each Ctl In Application.CommandBars(Cbar).Controls
Application.CommandBars(Cbar).FindControl(ID:=21, _
Recursive:=True).Enabled = False
Next Ctl
Next Cbar
On Error GoTo 0
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top