Protecting and unprotecting form fields

B

Bill

I have a form that I saved as a template, so that I can insert it into
various documents. I have written code that inserts this form using a macro
that does that and also opens a userform. The form has bookmarks and form
fields with options and drop downs that only work when the form is protected.
I need the form unprotected so that I can insert information from the
userform into specific bookmarks, but then need it protected after that, so
the form field options and drop downs will work. Is there code I can run in
the userform when the form is inserted that will unprotect it until the
infomation is sent to the bookmarks, and then code I can run to protect the
form so the form field options and drop down will work when I exit the
userform, or do I have to manually open the toolbars from the [View]
[Toolbars] [Forms] menu? Thanks!
 
D

Doug Robbins - Word MVP

You can use

[Document Object].Unprotect

[your code to insert into the bookmarks]

[Document Object].Protect wdAllowOnlyFormFields NoReset

where [Document Object] is a reference to the 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
 
B

Bill

Thanks Doug. This did the trick!
--
Bill


Doug Robbins - Word MVP said:
You can use

[Document Object].Unprotect

[your code to insert into the bookmarks]

[Document Object].Protect wdAllowOnlyFormFields NoReset

where [Document Object] is a reference to the 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

Bill said:
I have a form that I saved as a template, so that I can insert it into
various documents. I have written code that inserts this form using a
macro
that does that and also opens a userform. The form has bookmarks and form
fields with options and drop downs that only work when the form is
protected.
I need the form unprotected so that I can insert information from the
userform into specific bookmarks, but then need it protected after that,
so
the form field options and drop downs will work. Is there code I can run
in
the userform when the form is inserted that will unprotect it until the
infomation is sent to the bookmarks, and then code I can run to protect
the
form so the form field options and drop down will work when I exit the
userform, or do I have to manually open the toolbars from the [View]
[Toolbars] [Forms] menu? Thanks!
 

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