ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Copy (https://www.excelbanter.com/excel-programming/332908-disable-copy.html)

Nick S[_5_]

Disable Copy
 

Is it possible to disable the copy and paste function without protecting
sheets.

Thanks

Nick


--
Nick S
------------------------------------------------------------------------
Nick S's Profile: http://www.excelforum.com/member.php...o&userid=16512
View this thread: http://www.excelforum.com/showthread...hreadid=382437


dominicb[_45_]

Disable Copy
 

Good afternoon Nick S

This type of request can be tricky, in that it is very easy to disabl
the menu, but there are keyboard shortcuts to consider and th
rightclcik menu to worry about, so the easiest way is to introduce
short single command macro into the ThisWorkbook that will empty th
clipboard every time an active cell changes:

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVa
Target As Range)
Application.CutCopyMode = False
End Sub

This will do the trick, by allowing a user to copy, but not paste. Ad
this and it will prevent a user pasting something outside the curren
sheet:

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CutCopyMode = False
End Sub

The downside : this code relies on the user opting to run the macros o
the sheet opening, if they say no to the "Run macros" question the cod
will be useless.

HTH

Dominic

--
dominic
-----------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893
View this thread: http://www.excelforum.com/showthread.php?threadid=38243


DM Unseen

Disable Copy
 
Nick,

you can disable/control key shortcuts like CTRL+c etc with
Application.Onkey function by e.g. checking sheetname first before
allowing copying.

You could assign new macro's to Cut/copy paste buttons or just add code
to them using event sinking(Excel 2000 and later). Especially sinking
the events of all the cut/copy/paste buttons should be considered
advanced VBA.

some test code:

Public Sub nocopy()

If ActiveSheet.Name = "Sheet1" Then
MsgBox "nocopy"
Else
Application.CommandBars.FindControl(, 21).Execute ' execute
copy button
End If

End Sub

Sub test()
Application.OnKey "^c", "nocopy"
End Sub

DM Unseen


Nick S[_6_]

Disable Copy
 

That does the tric

--
Nick
-----------------------------------------------------------------------
Nick S's Profile: http://www.excelforum.com/member.php...fo&userid=1651
View this thread: http://www.excelforum.com/showthread.php?threadid=38243



All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com