D
David
I have a macro I want to send out to multiple locations, but there are two
possible passwords for the sheet I need to manipulate.
I would like to have the macro test the sheet to see if it is password
protected, if it is, try the first password, test to see if it was unlocked,
if so, write that password to the password string (to reprotect using the
same password). If the test shows the sheet is still locked, then try the 2nd
password (I'll include both passwords in the script), then test again, if
unlocked, then write the 2nd password to the string.
I've come up with the following code, but it's not doing anything. I think
the variable is wrong. Any ideas?
'Start Password Checker
With ActiveSheet
If ActiveSheet.ProtectionMode Then ' not working, it's always True
..Unprotect password:="pass1"
If ActiveSheet.ProtectionMode = False Then
password = "pass1"
Else
.Unprotect password:="pass2"
password = "pass2"
End If
End If
End With
ActiveSheet.Unprotect (password)
'End Password Checker
possible passwords for the sheet I need to manipulate.
I would like to have the macro test the sheet to see if it is password
protected, if it is, try the first password, test to see if it was unlocked,
if so, write that password to the password string (to reprotect using the
same password). If the test shows the sheet is still locked, then try the 2nd
password (I'll include both passwords in the script), then test again, if
unlocked, then write the 2nd password to the string.
I've come up with the following code, but it's not doing anything. I think
the variable is wrong. Any ideas?
'Start Password Checker
With ActiveSheet
If ActiveSheet.ProtectionMode Then ' not working, it's always True
..Unprotect password:="pass1"
If ActiveSheet.ProtectionMode = False Then
password = "pass1"
Else
.Unprotect password:="pass2"
password = "pass2"
End If
End If
End With
ActiveSheet.Unprotect (password)
'End Password Checker