View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Varne Varne is offline
external usenet poster
 
Posts: 126
Default Disabling Cut and Copy

Hi

That is brilliant.

I am trying on stoppying copying .

Many thanks.
M Varnendra

"Jim Rech" wrote:

This is a way to disable Cuts (and Drag & Drop, which is the same thing).
You would have to enhance it yourself for copying.

Sub CutsOff()
AllowCuts False
End Sub

Sub CutsOn()
AllowCuts True
End Sub

Sub AllowCuts(bEnable As Boolean)
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 = bEnable
Next
End If
''Disable Tools, Options so D&D cannot be restored
Set oCtls = CommandBars.FindControls(ID:=522)
If Not oCtls Is Nothing Then
For Each oCtl In oCtls
oCtl.Enabled = bEnable
Next
End If
With Application
.CellDragAndDrop = bEnable
If bEnable Then
.OnKey "^x"
.OnKey "+{Del}"
Else
.OnKey "^x", ""
.OnKey "+{Del}", ""
End If
End With
End Sub


--
Jim
"Varne" wrote in message
...
| Hi
|
| Is it possible to disable cut and copy functions in Excel through VBA
codes?
|
| If yes could somebody show the codes please?
|
| Thank You.
|
| M Varnendra