rng.InsertBefore and Protected Documents

T

Tim Ferguson

Dear all

I am just getting to grips with Word Formfields and document protection and
have come across a couple of related problems.

1) A section of the (paper) form has a blank area for people to write in as
many relatives as possible, on one each line. I have replicated this by
having one line of text boxes, and the last one has an Exit procedure that
creates a string out of the results, and uses rng.InsertBefore to insert
it, pushing the row of fields down for another go. This works rather well.

2) The last page of the form has a huge list of possible contacts, most of
which would be blank but any combination might need name, base and phone
details filled in. With this I have used a check box for each contact and
the exit sub here opens a userform, which is meant to concatenate the
results into a string and use rng.InsertBefore to put it into the document.

Trouble is that I am getting very inconsistent error messages about not
being able to complete the action because that part of the document is
protected. Usually (1) works, and (2) doesn't.

I can post the code if you'd like, but I rather hoped that there would be
some rules about how I can write to a protected document and when I can't.

Thanks is advance

Tim F
 
P

Peter Hewett

Hi Tim

It's called a Protected Document exactly because you cannot change it's
layout,formatting or text - Just the FormFields! If you need to change any
of the preceeding, this is wot you do:

' Get access to the document
ActiveDocument.Unprotect

' Make any updates to your document here
' .....

' Protect your document again (reactivate the FormFields) without
' losing their values
ActiveDocument.Protect wdAllowOnlyFormFields, True

With Word 97 - Word XP: If your document has more than 1 section you can
choose which sections to protect. With Word 2003 I understand that you can
choose ranges of characters to not be protected.

HTH + Cheers - Peter
 
T

Tim Ferguson

Hi Tim

It's called a Protected Document exactly because you cannot change
it's layout,formatting or text - Just the FormFields! If you need to
change any of the preceeding, this is wot you do:

Groan: it seems a really kludgy way of doing things, and in any case Word
2002 _does_ allow some of these updates. Thanks anyway: I guess I'll have
to go with the Unprotect/ Reprotect route.

B Wishes

Tim F
 

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