Removing Cut, copy and Paste

Daniel C

New Member
Joined
Mar 3, 2006
Messages
10
Hi
using the search facility i've cobbeld together this code in order to help remove the cut copy and paste functions.

Private Sub Workbook_Open()
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("PasteSpecial").Delete
On Error GoTo 0
Application.CommandBars("Standard").Visible = False
End sub

However you can still use the the Worksheet command bar > Edit > cut

I originally thought that may be
Application.CommandBars("worksheet menu bar").Visible = False

would work but to no avail, what should i do?
Dan
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

DominicB

Well-known Member
Joined
Oct 3, 2005
Messages
1,569
Good afternoon Daniel C

Try this :

Code:
Sub Test()
Dim ctrl As Object, ctrlMenuItem As Object
For Each ctrl In CommandBars("Worksheet Menu Bar").Controls
If ctrl.Caption = "&Edit" Then
For Each ctrlMenuItem In ctrl.Controls
If ctrlMenuItem.Caption = "Cu&t" Then ctrlMenuItem.Enabled = False ' Change to true to restore
If ctrlMenuItem.Caption = "&Copy" Then ctrlMenuItem.Enabled = False ' Change to true to restore
Next ctrlMenuItem
End If
Next ctrl
End Sub

FWIW, Ivan F Moala has put together a routine which prevents copying and pasting here :

http://www.xcelfiles.com/VBA_Quick13.html

HTH

DominicB
 

Watch MrExcel Video

Forum statistics

Threads
1,111,490
Messages
5,541,028
Members
410,540
Latest member
FlaShow
Top