Disabling "cut" function - version 2003/2007

  • Thread starter Thread starter wlam
  • Start date Start date
W

wlam

Does any one know how to disable "cut" function in a protected worksheet? By
allowing cutting in unprotected cell, it is messing up the formula that I put
in the protected cell which is related to that unprotected cell.
 
Hi there wlam,

Paste this code in the "ThisWorkbook" VBA code module of the workbook you
want to protect.

Code is below.
-----------------------

Const DisableCutOperations As Boolean = True

Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
If DisableCutOperations = False Then Exit Sub
Set CutButton = Application.CommandBars("Worksheet Menu Bar"). _
Controls("edit").CommandBar.Controls("Cut")
CutButton.OnAction = "ThisWorkbook.DisableCut"
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
Set CutButton = Application.CommandBars("Worksheet Menu Bar"). _
Controls("edit").CommandBar.Controls("Cut")
CutButton.OnAction = Cut
End Sub

Sub DisableCut()
If DisableCutOperations = False Then Exit Sub
If ActiveWorkbook.Name = ThisWorkbook.Name Then
dummy = MsgBox("Do NOT use the cut function in this Workbook please.
", _
vbInformation, ActiveWorkbook.Name)
Exit Sub
Else: Selection.Cut
End If
End Sub
 
Back
Top