Prevent modification of values on a protected Excel file
I developed an Excel file that I protected by a password.
This file contains cells with input pull-down menus with the tool set/validation list.
The problem is that even when the file is protected, you can edit, copy and paste on these cells, and it overwrites the dropdown! How to prevent modification? Or only allow pasting Special Value?
Re: Prevent modification of values on a protected Excel file
Code:
Option Explicit
Sub DisableCopyCutAndPaste ()
EnableControl 21, False 'cut
EnableControl 19, False 'copy
EnableControl 22, False 'paste
EnableControl 755, False 'pastespecial
Implementation. On Key "^ c", "Dummy"
Key Application.On "^ v", "Dummy"
Application.On Key "+ (DEL)", "Dummy"
Application.On Key "+ (INSERT)", "Dummy"
Application.CellDragAndDrop = False
Application.On DoubleClick = "Dummy"
CommandBars ("ToolBar List"). Enabled = False
End Sub
Sub EnableCopyCutAndPaste ()
EnableControl 21, True 'cut
EnableControl 19, True 'copy
EnableControl 22, True 'paste
EnableControl 755, True 'pastespecial
Key Application.On "^ c"
Key Application.On "^ v"
Application.On Key "+ (DEL)"
Application.On Key "+ (INSERT)"
Application.CellDragAndDrop = True
Application.On DoubleClick = ""
CommandBars ("ToolBar List"). Enabled = True
End Sub
Sub EnableControl (Id As in protecting, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
On Error Resume Next
For Each CB In Application.CommandBars
Set C = CB.FindControl (Id: = Id, recursive: = True)
If Not C Is Not hing Then C. Enabled = Enabled
Next
End Sub
Sub Dummy ()
'// Nogo
MsgBox "Sorry command not Available!"
End Sub
Re: Prevent modification of values on a protected Excel file
Clicking on a cell, then by going to Format/cell you should see a tab "Protection", to protect it.
But it would be interesting to know first that overwrites your cells and why.
If it's malicious, but unfortunately there is no simple solution.
If it is through carelessness, then you must use cells that are located in a quiet place. For example, taking cells that are not in the first columns, or not in the first few lines, or not in the first sheet.
Re: Prevent modification of values on a protected Excel file
But in fact, it should not be protected because it is a cell attachment!
I just want the users can not change the format by pasting or otherwise.
Re: Prevent modification of values on a protected Excel file
This should help:
Code:
Private Sub Workbook_Open ()
'Ban the draw of formulas in 4 directions and the slide move
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_SheetSelectionChange (ByVal Sh As Object, ByVal Target As Range)
'Ban the collage on the same sheet as that used to copy
Application.CutCopyMode = False
End Sub
Private Sub Workbook_Activate ()
'Forbidden bonding after a copy from another workbook
Application.CutCopyMode = False
End Sub
Private Sub Workbook_SheetActivate ()
'Forbidden bonding after a copy from another sheet same workbook
Application.CutCopyMode = False
End Sub
Private Sub Workbook_BeforeClose (Cancel As Boolean)
'Active drawing of formulas in 4 directions and
'the technique of drag and drop to the cells.
Application.CellDragAndDrop = True
'Active possible bonding
Application.CutCopyMode = True
End Sub
Re: Prevent modification of values on a protected Excel file
This activity has been password protected to prevent modification. In order to request an ... these values. Compare your values with your group members. .... Plot the following data using Excel and determine the highest .