Protected Document

K

Ken Wheeler

I am attempting to open word from an application have have the document
protected by sections. For some reason If I have the right sections protected
the bookmarks are unable to auto fill upon opening the document from our
database. It pulls the information fine when the document is not protected,
but as soon as it's protected in any form it will not auto fill those
bookmarks. I need the documents protected for certain fields to allow for
users to tab to each bookmark and enter the required information for the
form.

Any help? (e-mail address removed) or reply to this.
 
M

macropod

Hi Ken,

Are you trying to populate bookmarks or formfields? I can understand that you wouldn't be able to populate the former if the
document is protected, but you should still be able to populate the latter.

If you're trying to populate bookmarks, you'll need to work with the unprotected document, then protect it for forms after
populating the bookmarks, not before. Alternatively, if your requirements allow it, put the bookmarks in unprotected Sections.

If you're trying to populate formfields with no more than 255 characters, you can use something like:
ActiveDocument.FormFields("Text1").Result = "My short text string"
If you need to insert more than 255 characters, you'll need to unprotect the document and use something like:
ActiveDocument.Bookmarks("Text1").Range.Fields(1).Result.Text = "My life story"

To (re)protect the document without losing/resetting any formfield contents, use something like:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="Password"
 
K

Ken Wheeler

Thanks for the help. I am taking data from our database in oracle and auto
filling bookmarks in templates. Most templates require auto filling of some
sort and then allowing other bookmarks on the template to be a fillable form.
The bookmarks that are filled in by the user is only saved with that
particular document and used to distribute the document via email/mail/fax.

Your response helps a lot as I look to throw some code at my forms and have
it open the document, fill the fields in and then protect the document. I
wanted to try and protect the document on the front end as that would be less
time consuming, but have found that it's not possible to have it to as I want.

Thanks for your help. I appreciate such a quick response.


macropod said:
Hi Ken,

Are you trying to populate bookmarks or formfields? I can understand that you wouldn't be able to populate the former if the
document is protected, but you should still be able to populate the latter.

If you're trying to populate bookmarks, you'll need to work with the unprotected document, then protect it for forms after
populating the bookmarks, not before. Alternatively, if your requirements allow it, put the bookmarks in unprotected Sections.

If you're trying to populate formfields with no more than 255 characters, you can use something like:
ActiveDocument.FormFields("Text1").Result = "My short text string"
If you need to insert more than 255 characters, you'll need to unprotect the document and use something like:
ActiveDocument.Bookmarks("Text1").Range.Fields(1).Result.Text = "My life story"

To (re)protect the document without losing/resetting any formfield contents, use something like:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:="Password"

--
Cheers
macropod
[MVP - Microsoft Word]


Ken Wheeler said:
I am attempting to open word from an application have have the document
protected by sections. For some reason If I have the right sections protected
the bookmarks are unable to auto fill upon opening the document from our
database. It pulls the information fine when the document is not protected,
but as soon as it's protected in any form it will not auto fill those
bookmarks. I need the documents protected for certain fields to allow for
users to tab to each bookmark and enter the required information for the
form.

Any help? (e-mail address removed) or reply to this.
 

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