Turn on protection of form

R

Ricki Miles

I am creating an AutoNew macro for a template that will create a form. The
form uses form fields as well as other fields. When the form is first
opened, the AutoNew macro updates all fields, then it needs to set the
protection on for forms, Since this cannot be done while recording, I would
like to know the VBA language to include as the last line of the macro so
the protection will be turned on.

Thanks,

TIA
 
J

Jay Freedman

Hi Ricki

Use this:

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

The NoReset:=True tells Word not to clear the form fields as it turns
on the protection. If the form fields are empty when the macro runs,
you can omit that and the comma that precedes it. (It won't hurt to
have it there, it's just unnecessary in that case.)
 
R

Ricki Miles

Thanks Jay,

It works perfectly.

Ricki



Jay Freedman said:
Hi Ricki

Use this:

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

The NoReset:=True tells Word not to clear the form fields as it turns
on the protection. If the form fields are empty when the macro runs,
you can omit that and the comma that precedes it. (It won't hurt to
have it there, it's just unnecessary in that case.)
 

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