protected doc

P

Pammy

In word, can you create a macro to unprotect a doc insert a new blank file
and then protect the doc. I am creating the macro with no problem to insert
a blank copy, but cannot figure out how to make the macro unprotect and then
protect. I have word 2003, and am not familiar with writing code. Thanks,
 
J

Jay Freedman

Pammy said:
In word, can you create a macro to unprotect a doc insert a new blank
file and then protect the doc. I am creating the macro with no
problem to insert a blank copy, but cannot figure out how to make the
macro unprotect and then protect. I have word 2003, and am not
familiar with writing code. Thanks,

At the beginning of the macro, add this code to turn off protection:

If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If

At the end, add this line to turn forms protection on again, without
clearing any fields that already contain data:

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Any further questions about macros should be posted in one of the VBA
groups,
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.word.vba.beginners
or
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.word.vba.general.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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