Disable ability to CUT

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a protected file, that has unprotected data input
fields. Is there any way to disable the CUT function, so
that users can't cut and paste (as this causes
problems). It's OK if they copy and paste.

Thanks.
 
To stop users from being able to do a cut requires a macro. The macro has
to disable the Cut command wherever as occurs. It also has to disable the
Ctrl-x and Shift-Del keyboard shortcuts. Drag and Drop also has to be
disabled, and blocked from being turned back on.

And all these things have to be reset when you're done too. My sample
macros are below. You'd have to run the disable macro when the users opens
your workbook or at least before data entry starts. So you could use the
Workbook_Open event. And you'd run the resetting macro when the workbook
closes.

But it gets even more complicated if you want users to be able to switch to
other workbooks and allow them to cut, etc. there. Then you have to use the
activate and deactive events to turn cutting on and off.

--
Jim Rech
Excel MVP

Sub DisableCuts()
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21) ''Cut
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522) ''Options
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = False
Next
End If
With Application
.OnKey "^x", ""
.OnKey "+{Del}", ""
.CellDragAndDrop = False
End With
End Sub

Sub EnableCuts()
Dim oCtls As CommandBarControls, oCtl As CommandBarControl
Set oCtls = CommandBars.FindControls(ID:=21)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = True
Next
End If
With Application
.OnKey "^x"
.OnKey "+{Del}"
.CellDragAndDrop = True
End With
End Sub
 
Back
Top