problem with protected and secured with password templeate!

P

pieohpah

Hi - hopefully this is my last post concerning this document :) Its
allmost done now and would like to go on making other forms :)

I have this form which is protected - and everything works fine. The
macros run smooth and so forth.
The problem stats if I decide to insert a password with the protection
- after that the macros wont run cause the cant undo the protection on
the document and then protect the Doc. again,

I havent any problems with the password beeing written in the macro -
but can It be done? and how? :)

Yours
Særen Vejle
 
D

Doug Robbins - Word MVP

From the Help File:

ActiveDocument.Unprotect Password:=strPassword

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

Hi - hopefully this is my last post concerning this document :) Its
allmost done now and would like to go on making other forms :)

I have this form which is protected - and everything works fine. The
macros run smooth and so forth.
The problem stats if I decide to insert a password with the protection
- after that the macros wont run cause the cant undo the protection on
the document and then protect the Doc. again,

I havent any problems with the password beeing written in the macro -
but can It be done? and how? :)

Yours
Særen Vejle
 
G

Graham Mayor

To elaborate on Doug's reply:


Dim bProtected As Boolean


'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:="password"

End If

'Do your stuff here


'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="password"
End If


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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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