unprotect then protect document...

J

Jade

Hi All,

I need help.

I have a template which is being auto populated with data from an
outlook form. Everything pretty much works like a charm; however,
since the template is protected I need to unprotect the document in
order to allow it to populate then protect it once again.

Can someone help me with the proper syntax or show me where I can find
the answers....I've researched this usergroup and although i've gained
a lot of insight...I'm now a bit more confused as well.

Any help would be so great.

Here's what i have:


set myApp=createobject("Word.Application")
myApp.documents.add(strName)
myApp.visible=true
 
D

Doug Robbins - Word MVP

ActiveDocument.Unprotect will remove the protection

ActiveDocument.Protect wdAllowOnlyFormfields will re-apply protection.

--
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
 
J

Jade

ActiveDocument.Unprotect will remove the protection

ActiveDocument.Protect wdAllowOnlyFormfields will re-apply protection.

--
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












- Show quoted text -

Hi Doug,

Thanks for the reply. I've added those steps yet when I check the
document it's not protected.
Should I re-enter the password to protect it?

for example: activedocument.protect wdAllowOnlyFormFields,
NoReset:=True, Password:=strName1
 
D

Doug Robbins - Word MVP

The code is probably not being executed on the document to which you want to
apply the protect.

Do something like

Dim mydoc as Document
set myApp=createobject("Word.Application")
Set mydoc = myApp.documents.add(strName)
myApp.visible=true

mydoc.Unprotect, Password:=strName1

etc.

mydoc.Protect wdAllowOnlyFormFields, No Reset, Password:=strName1

Then you are sure that the code is being executed on the relevant document.

--
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
 
J

Jade

The code is probably not being executed on the document to which you want to
apply the protect.

Do something like

Dim mydoc as Document
set myApp=createobject("Word.Application")
Set mydoc = myApp.documents.add(strName)
myApp.visible=true

mydoc.Unprotect, Password:=strName1

etc.

mydoc.Protect wdAllowOnlyFormFields, No Reset, Password:=strName1

Then you are sure that the code is being executed on the relevant document.

--
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









- Show quoted text -

Hi Doug,

Unfortunately, it's not working as it should. The data is populated
into the document; however, the code where it instructs the document
to protect itself isn't being executed.

Not sure if I should add all the parameters invovled in protecting the
doc.

Any guidance would be great.

Thank you.
 
D

Doug Robbins - Word MVP

Without seeing all of your code, it is not possible to say what is causing
the problem.

--
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
 

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