I have been working on the code in this workbook all day, and have everything else finally working except for this last piece.
My goal is that if someone tries to paste into the workbook, they will only get the option to paste 'values' in order to protect the Data Validations. I can get it to work if I Ctrl+C in another workbook, but not if I use the GUI context menu to choose Copy | Paste from another workbook.
Also open to other suggestions for improvement, but didn't want to bog this post down with an explanation of everything else the code is doing other than the one problem I have remaining.
paste_data validation controls template.xlsm
Here is the code for the paste restrictions:
Sub PasteValues()
' Keyboard Shortcut: Ctrl+v
On Error Resume Next
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
Sub Auto_Open()
Application.CommandBars("Cell").Reset
With Application.CommandBars("Cell")
.Controls("Paste").OnAction = "PasteValues" ' Changes right click cell paste to use Pastevalues macro
.Controls(4).Delete ' removes paste secial option
End With
Application.CommandBars("Row").Reset
With Application.CommandBars("Row")
.Controls("Paste").OnAction = "PasteValues" ' Changes right click row paste to use Pastevalues macro
.Controls(4).Delete ' removes paste secial option
End With
Application.CommandBars("Column").Reset
With Application.CommandBars("Column")
.Controls("Paste").OnAction = "PasteValues" ' Changes right click column paste to use Pastevalues macro
.Controls(4).Delete ' removes paste secial option
End With
Application.CommandBars("Worksheet Menu Bar").Reset
With Application.CommandBars("Worksheet Menu Bar").Controls
.Item(2).Controls(6).OnAction = "PasteValues" ' changes edit/paste to use Pastevalues macro
.Item(2).Controls(7).Enabled = False ' disable paste special
End With
Application.CommandBars("Standard").Reset
With Application.CommandBars("Standard").Controls.Item(12)
.Enabled = False
End With
End Sub
Bookmarks