banner_ad

Disable copy paste

Excel for Finance 1258 views 1 replies

The following code was previously posted to disable copy/paste.

It includes a message box to notify the user that right click has been disabled.

I would like to know how to add code to include a message box to notify the user that cut/copy has been disabled when the shortcut keys (control x/control c) are used.

Thank you in advance for any assistance!

Private Sub Workbook_Activate()
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_Deactivate()
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_WindowActivate(ByVal Wn As Window)
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub

Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right click menu deactivated." & vbCrLf & _
"Cannot copy or ''drag & drop''.", 16, "For this workbook:"
End Sub

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

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
Application.CutCopyMode = False
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Application.CutCopyMode = False
End Sub

Replies (1)

Please update how it's worked.

Thanks in advance

Rakesh


CCI Pro

Leave a Reply

Your are not logged in . Please login to post replies

Click here to Login / Register  

Company
19 May 2026
Accountant

ca kunjan

Mumbai

CA Inter

View Details
Company
26 May 2026
Senior Accountant cum purchase Manager

Vardhaman Group of India

Pimpri Chinchwad

CA Inter

View Details
Company
ARTICLESHIP 27 May 2026
CA Article Trainee

Rahul Dang & Associates-Chartered Accountants

Pune

CA Inter

View Details
Company
Featured 28 May 2026
SEMI QUALIFIED/ CA DROPOUTS/ ARTICLES

T R SOOD & CO

New Delhi

CA Inter

View Details
Company
19 May 2026
Article, CA & Paid Assistant Positions

Aggarwal Sarawagi and Co

New Delhi

CA

View Details
Company
14 May 2026
Senior Accounts Executive

Karan Gupta & Co.

New Delhi

Graduate (Any)

View Details
Company
23 May 2026
Account Executive

SMJ global advisors pvt ltd

New Delhi

B.Com

View Details
Company
18 May 2026
MIS Executive

Primarc Pecan Retail Limited

Mumbai

B.Com

View Details