Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2007

Tip: Looking for answers? Try searching our database.

VB Error message "The Password is incorrect"?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Armey - 18 Jan 2007 00:32 GMT
I have a protected word template that I have created with several
formfields.  I have written the VBA code as well and it all meets with
my user requirements.  The problem is that when I protect the word
template "Tools, Protect Document" with the editing restrictions set to
"Filling in Forms" I get the Visual Basic Error of "The Password is
incorrect" when I exit my first drop-down formfield exit macro event.
If I turn off the document password protection, everything works fine,
but I really need to protect my template so users wont make
unauthorized changes.  Also, if i use the protect Form option and dont
set a password as described above, everything works fine.  Any ideas
from anyone?  Your thoughts are appreciated.

I am using the .Unprotect call as listed in my example below.  I am not
sure if the way I am calling this if this is the problem?

MyDropDown()

With ActiveDocument
.Unprotect

---my code here---

.Protect wdAllowOnlyFormFields, NoReset
End With

End Sub

Armey
Graham Mayor - 18 Jan 2007 08:03 GMT
You are not passing the password to the macro?

ActiveDocument.Unprotect Password:="password"
**********
ActiveDocument.Protect _
 Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="password"

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I have a protected word template that I have created with several
> formfields.  I have written the VBA code as well and it all meets with
[quoted text clipped - 24 lines]
>
> Armey
Armey - 18 Jan 2007 23:16 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
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.