Establish the Unprotect Password - Excel VBA

Closed
jrheeder
Posts
1
Registration date
Monday July 26, 2010
Status
Member
Last seen
July 26, 2010
- Jul 26, 2010 at 05:40 AM
rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
- Jul 30, 2010 at 09:34 AM
Hello,

I recently sent out about 200 workbooks, half with one protect password and the rest with another (for this purpose we will make the passwords passA and passB). What I am trying to do via Excel macro is establish what password that sheet is using.

Now I have tried
If IsError(ActiveSheet.Uprotect ("passA")) = False then
...
else if IsError(ActiveSheet.Uprotect ("passB")) = False then
...
end if

Now of course this doesn't work... any advise?

Regards,

1 reply

rizvisa1
Posts
4479
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
769
Jul 30, 2010 at 09:34 AM
Try to unprotect sheet with one password, then check if the sheet was unprotected. For that you can use

if (ActiveSheet.ProtectContents) then
msgbox "this is a good password"
else
msgbox "this is not so good password"

end if
0