First, thanks to mole999 for the help with the first phase of this. I thought I'd be able to use the principles to implement the next phase, but my limited VBA knowledge and research hasn't been enough.
I am trying to have cut, copy, and paste inactive for most users, but if the user enters a password, it will allow cut, copy, paste ("admin" level access, if you will). I was able to find the code to disable cut, copy, paste, and mole999 helped me with referencing a cell value to disable the code (i.e. if A1="X" then exit sub).
What I am trying to do is allow users with the proper password disable the code (X in a cell isn't quite practical) so that they can cut, copy, and paste.
I thought I could use Application.Run to pass the password string to the subs and then use If/Then within the sub to disable the sub when the password is correct. When I try various methods I get a Run-Time error '1004': Application defined or object-defined error.
Any help is greatly appreciated!
I am trying to have cut, copy, and paste inactive for most users, but if the user enters a password, it will allow cut, copy, paste ("admin" level access, if you will). I was able to find the code to disable cut, copy, paste, and mole999 helped me with referencing a cell value to disable the code (i.e. if A1="X" then exit sub).
What I am trying to do is allow users with the proper password disable the code (X in a cell isn't quite practical) so that they can cut, copy, and paste.
I thought I could use Application.Run to pass the password string to the subs and then use If/Then within the sub to disable the sub when the password is correct. When I try various methods I get a Run-Time error '1004': Application defined or object-defined error.
Any help is greatly appreciated!
Code:
Sub GetPassword()Dim strPassword As String
strPassword = InputBox(Prompt:="Your password please:", _
Title:="ENTER YOUR PASSWORD", Default:="Your Password here")
Application.Run "Workbook_Activate", strPassword
End Sub
Private Sub Workbook_Activate()
If strPassword = "Password" Then Exit Sub
If strPassword <> "Password" Or _
strPassword = vbNullString Then
End If
Application.CutCopyMode = False
Application.OnKey "^c", ""
Application.CellDragAndDrop = False
End Sub
Private Sub Workbook_Deactivate()
If ActiveSheet.Range("A1") = "X" Then Exit Sub
'This looks for a case sensitive X in cell A1 on the live sheet, exit sub stops the follow on rules that would disable Cut / Copy
If UCase(ActiveSheet.Range("A1")) = "X" Then Exit Sub
'This allows for x or X to be inputted
Application.CellDragAndDrop = True
Application.OnKey "^c"
Application.CutCopyMode = False
End Sub