LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Check for Sheet Password Protected, Unprotect with multiple passwo

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
unprotect check box in protected worksheet Laura Bennett Excel Discussion (Misc queries) 1 September 12th 06 05:12 PM
password protected a check box Glendon MacBurnie Excel Worksheet Functions 0 January 27th 05 07:52 PM
How can I unprotect a worksheet that is password protected Password Excel Discussion (Misc queries) 3 December 30th 04 06:13 PM
How can i unprotect a workbook in Excell when I forgot the passwo. Kevin1961 Excel Worksheet Functions 2 October 29th 04 08:58 AM


All times are GMT +1. The time now is 12:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"