Multiple asswords protected documents

K

Ken Curtis

Hi,

I have several hundred forms that are pasword protected. SpellCheck does
not run on pasword protected forms. In order to run SpellCheck I have
installed a VB script that allows SpellCheck to run. This script is based on
a single password. However, there are two passwords. How do I add the second
password to the following script so that SpellCheck works on both passwords.

oDoc.Unprotect Password:="mazie"

Thanks, Ken
 
J

Jim F

Ken here is some code that might get you started: It's not pretty but it
works.

Public Sub UnProtectMe()
On Error GoTo TryDifferntPWD:
Dim i As Integer
i = 1
Dim myPWD As New Collection 'Creates A collection of possible passwords
With myPWD
.Add ("virgo")
.Add ("joe")
.Add ("test")
.Add ("xPWDx")
.Add ("jim")
End With


oDoc.Unprotect Password:=myPWD(i) 'myPWD(i) returns the data located in
"myPWD" collection at the given index

Exit Sub

TryDifferntPWD:

i = i + 1 'On error it increments the counter
If i <= myPWD.Count Then 'Exits the loop after all passwords in the
list have been tried
Resume 'returns to the line of code that caused the error
"oDoc.Unprotect Password:=myPWD(i)"
Else
MsgBox ("Can not determine password")
End If

End Sub
 

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