How do I disable the right mouse cut and paste facility?

DexonII

New Member
Joined
Sep 8, 2005
Messages
34
I need to be able to prevent any user from cutting and pasting data in one of my spreadsheets. I have protected it all, removed cut and paste from the options- edit tab, but you can still cut and paste with the right mouse shortcut key.

How do I stop this from being available?

Paul.
 
The following will disable the menu items globally

Code:
Sub Disable_cut_copy_paste()
Application.CutCopyMode = False
Application.OnKey "^{c}", "" 'Copy
Application.OnKey "^{v}", "" 'Paste
Application.OnKey "^{x}", "" 'Cut
On Error Resume Next
ShortcutMenus(xlWorksheetCell).MenuItems("Cut").Delete
ShortcutMenus(xlWorksheetCell).MenuItems("Copy").Delete
ShortcutMenus(xlWorksheetCell).MenuItems("Paste").Delete
ShortcutMenus(xlWorksheetCell).MenuItems("Paste Special...").Delete 'Note space and ...
With CommandBars("Worksheet Menu Bar")
    With .Controls("Edit")
        .Controls("Cut").Enabled = False
        .Controls("Copy").Enabled = False
        .Controls("Paste").Enabled = False
        .Controls("Paste Special...").Enabled = False
    End With
End With
On Error GoTo 0
End Sub

Therefore it is important to re-enable them by running the following before the workbook is closed:

Code:
Sub ResetMenu()
With CommandBars("Worksheet Menu Bar")
    With .Controls("Edit")
        .Controls("Cut").Enabled = True
        .Controls("Copy").Enabled = True
        .Controls("Paste").Enabled = True
        .Controls("Paste Special...").Enabled = True
    End With
End With
End Sub

Edit: the easiest way of doing this is with a routine in the Workbook code:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call RestoreMenu
End Sub
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
VoG,

That all now works like a dream! Thank you so much for all your help.

Hope I can return the favour some time.

Paul :pray:
 
Upvote 0
Deal All,

Excellent solution. Now the next "challange for me" please:

How does one include the menu /Format > Column > Hide (and Unhide) in this code? so that it is no longer possible to use these 2 options? Not globally of course.

Thanks already for the help.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top