Disable copy paste

1261 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

Leave a Reply

Your are not logged in . Please login to post replies

Click here to Login / Register  

Company
ARTICLESHIP 30 June 2026
2 posts Article assistant and Articleship completed students

Chirag N Shah & Associates

Mumbai

CA Inter

View Details
Company
24 June 2026
Chartered Accountant

CA Darshita Shah & Co

Nadiad

CA

View Details
Company
29 June 2026
Accountant (Finance & Compliance)

TRIEYEZ

Kolkata

CA

View Details
Company
ARTICLESHIP 30 June 2026
Taxation Content Writer Intern

Interactive Media Pvt Ltd.

New Delhi

CA Inter

View Details
Company
22 June 2026
Finance Manager- Chartered Accountant

Triveni Turbine Limited

Bengaluru

CA

View Details
Company
ARTICLESHIP 24 June 2026
CA Article Trainee

Rahul Dang & Associates

Pune

CA Inter

View Details
Company
ARTICLESHIP 27 June 2026
CA Articled Trainee And Paid Assistant

SKAA & Associates

New Delhi

CA Inter

View Details
Company
04 June 2026
Semi Qualified CA

Goyal Puneet & Associates

New Delhi

CA Final

View Details