
Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham, thank you! This worked great. I was wondering if I could put
the password in a module and reference it instead of putting the
password several times in my sub-routines?
I created a new module (module 1) and declared a public constant for my
password:
Public Const pw As String = "mypwstring"
Then in my VBA sub-routine I tried to reference the pw via the module
as follows:
Sub mySub()
With ActiveDocument
.Unprotect pw
.....
....
.Protect wdAllowOnlyFormFields, NoReset:=True, Password:=pw
End With
End Sub
I get error messages. What am I doing wrong when referencing the
password constant that I set up?
Thanks
> You are not passing the password to the macro?
>
[quoted text clipped - 39 lines]
> >
> > Armey
Jonathan West - 19 Jan 2007 13:22 GMT
> Graham, thank you! This worked great. I was wondering if I could put
> the password in a module and reference it instead of putting the
[quoted text clipped - 19 lines]
> I get error messages. What am I doing wrong when referencing the
> password constant that I set up?
I think your problem has nothing to do with the password. You are mixing
names and unnamed arguments in the same command. Don't. Either make them all
named or all unnamed. I generally prefer to make them all named except
perhaps for very simple, very commonly-used functions where I can easily
remember what the arguments are.
.Unprotect Password:=pw
...
.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=pw

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup