#1   Report Post  
Posted to microsoft.public.excel.misc
v.harikrish
 
Posts: n/a
Default Copy, Cut, Paste


Can I have the macro code which would disable 'cut & paste' but at the
same time allow 'copy & paste' in a workbook.


--
v.harikrish
------------------------------------------------------------------------
v.harikrish's Profile: http://www.excelforum.com/member.php...o&userid=31882
View this thread: http://www.excelforum.com/showthread...hreadid=516094

  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Rech
 
Posts: n/a
Default Copy, Cut, Paste

This code may help you. It also disables Copy but I commented those
sections out. Note that to disable Cut you also have to turn off Drag and
Drop, and disable Tools, Options so that D&D cannot be turned back on.

Dim DragDrop As Boolean

''Run this is disable Cut
Sub SetEunuchMode()
CopyCutOff False
End Sub

''Reset
Sub SetRegMode()
CopyCutOff True
End Sub

Sub CopyCutOff(OnOff As Boolean)
SetCtrl 21, OnOff ''Cut
'SetCtrl 19, OnOff ''Copy
SetCtrl 522, OnOff ''Options
CtrlKeys OnOff
CtrlDragDrop OnOff

''This controls whether
''View, Toolbars is enabled
''Commandbars context menu is enabled.
CommandBars("Toolbar List").Enabled = OnOff

If Val(Application.Version) = 10 Then SetDisableCustomize OnOff
End Sub

Sub SetCtrl(CtrlNum As Integer, Allow As Boolean)
Dim Ctrls As CommandBarControls
Dim Ctrl As CommandBarControl
Set Ctrls = CommandBars.FindControls(, CtrlNum)
If Not Ctrls Is Nothing Then
For Each Ctrl In Ctrls
Ctrl.Enabled = Allow
Next
End If
End Sub

Sub CtrlKeys(Allow As Boolean)
With Application
If Allow Then
.OnKey "^x"
.OnKey "+{DELETE}"
'.OnKey "^c"
'.OnKey "^{INSERT}"
Else
.OnKey "^x", ""
.OnKey "+{DELETE}", ""
'.OnKey "^c", ""
'.OnKey "^{INSERT}", ""
End If
End With
End Sub

Sub CtrlDragDrop(Allow As Boolean)
With Application
If Allow Then
.CellDragAndDrop = DragDrop
Else ''Kill
DragDrop = .CellDragAndDrop ''Save user's setting
.CellDragAndDrop = False
End If
End With
End Sub

''Must be in a sub that is only called if running Excel 2002 or later
''This controls whether
'' Customize menuitem appears on View, Toolbars **
'' Customize menuitem appears on commandbars context menu **
'' Customize dialog appears when toolbar area is double-clicked
'' Tools, Customize is enabled
''** These two effects aren't actually needed when
'' CommandBars("Toolbar List").Enabled = False is run as
'' above since the entire Toolbars menu is disabled but
'' no harm and we need the other two effects.
Sub SetDisableCustomize(OnOff As Boolean)
Application.CommandBars.DisableCustomize = Not OnOff
End Sub


--
Jim
"v.harikrish"
wrote in message
...
|
| Can I have the macro code which would disable 'cut & paste' but at the
| same time allow 'copy & paste' in a workbook.
|
|
| --
| v.harikrish
| ------------------------------------------------------------------------
| v.harikrish's Profile:
http://www.excelforum.com/member.php...o&userid=31882
| View this thread: http://www.excelforum.com/showthread...hreadid=516094
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy & paste spreadsheet cells from excel to outlook to excel mismarple Excel Discussion (Misc queries) 1 September 20th 05 11:16 PM
Copy and paste from one spreadsheet to another Calculate Date range Excel Worksheet Functions 2 September 17th 05 09:04 AM
Issue with copy & paste? Etrnal168 Excel Discussion (Misc queries) 2 July 12th 05 03:35 AM
Copy and Paste and keep format the same Brian Caraher Excel Discussion (Misc queries) 1 March 17th 05 02:05 PM
Copy & Paste Brian Keanie Excel Discussion (Misc queries) 1 February 5th 05 11:56 AM


All times are GMT +1. The time now is 06:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"