Use of multiple passwords in a macro

K

Ken White

Hi, and thanks for your anticipated help.

I did receive an answer earlier to this question but it seems I did not
express myself clearly in my original question. So I am trying again.

I use a macro that allows Spell Check to work in locked forms that are
protected by a password. Here is the line from the macro that gives the
password that unlocks the form: oDoc.Unprotect Password:="mazie"

I have hundreds of forms and many of them use a different password than the
one given above. My question: How do I add another password to the example
given above so that the one macro will open locked forms with different
passwords? Do I just write : ="mazie"or"toys"

I really appreciate your help, and all the tremendous knowledge you people
share with us. Thanks!
 
J

Jezebel

Ken's answer from last time was the right one. The code might look something
like --

Dim i as long
Dim pPassword as string
Dim pFailed as boolean

pFailed = True
On error resume next
For i = 1 to 5
pPassword = Choose(i, "Mazie", "Toys", ....)
err.clear
oDoc.Unprotect Password:=pPassword
if err.number = 0 then
pFailed = False
exit do
end if
Next
on error goto 0

If pFailed then
...failed
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top