Establish the Unprotect Password - Excel VBA

[Closed]
Report
Posts
1
Registration date
Monday July 26, 2010
Status
Member
Last seen
July 26, 2010
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
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

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
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