Hello all,
I was looking for a way to prevent other users of some workbooks I created, from copying and pasting my linestyles, formats, etc, wanting them, when they pasted, to allow them to only paste the values and formulas inside a specific range of cells.
So, I have found the next code that is already a good problem solver, preventing actually people from doing any copy or cut on the book, and while nearly never they copy outside information onto the book, trough some tests I found that if they want they can copy from an outside this book source, and paste it, most times pasting, and blocking that cell from being used, as most of my workbook is protected apart from that specific range of cells.
So, I am trying to find a modification to this bit of code, so that I allow people to copy, and paste only values and formulas. I would like to keep the right click option deactivated though, as it is a big help people not being able to access that quick menu.
Any thoughts on this?
The range of cells I want to be able to accept this solution are C9:Q20, C23:Q24, C27:Q50, and C53:Q78. Rest of the cells in the worksheets are protected. If it helps, the workbook as 10 worksheets.
Thanks in advance for the attention to the matter.
I was looking for a way to prevent other users of some workbooks I created, from copying and pasting my linestyles, formats, etc, wanting them, when they pasted, to allow them to only paste the values and formulas inside a specific range of cells.
So, I have found the next code that is already a good problem solver, preventing actually people from doing any copy or cut on the book, and while nearly never they copy outside information onto the book, trough some tests I found that if they want they can copy from an outside this book source, and paste it, most times pasting, and blocking that cell from being used, as most of my workbook is protected apart from that specific range of cells.
Code:
Private Sub Workbook_Activate()
Application.CutCopyMode = True
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''... MUHAHAHAHAHA!!!", 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
So, I am trying to find a modification to this bit of code, so that I allow people to copy, and paste only values and formulas. I would like to keep the right click option deactivated though, as it is a big help people not being able to access that quick menu.
Any thoughts on this?
The range of cells I want to be able to accept this solution are C9:Q20, C23:Q24, C27:Q50, and C53:Q78. Rest of the cells in the worksheets are protected. If it helps, the workbook as 10 worksheets.
Thanks in advance for the attention to the matter.