Maitaining form field info when unprotecting and reprotecting a document 
Author Message
 Maitaining form field info when unprotecting and reprotecting a document

Hi.  I have set up a Word template that has various text
fields as well as some checkbox fields.  After someone
fills out the template, a second person needs to run a
macro that unprotects the document and unhides a hidden
table within the template and the reprotects the
document.  However, when they unprotect and reprotect the
document, all of the data the original person entered into
the field is deleted.  I have been able to keep the text
fields on the other 2 tables in the document from losing
their values but have not been able to maintain the
checkbox values.  HOw can UI do that?

Here is the code I am using to maintain the text box
values just prio to re-prtecting the document:
ActiveDocument.Range.Tables(1).Select
    Selection.Fields.Unlink
ActiveDocument.Range.Tables(2).Select
    Selection.Fields.Unlink



Sat, 12 Feb 2005 20:47:06 GMT  
 Maitaining form field info when unprotecting and reprotecting a document
Hi, Chris,

The .Protect method takes parameters, one of which is NoReset.

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

If you omit NoReset from the command, its default value is False,
meaning that the original values are lost when reprotecting. When you
specifically say NoReset:=True the values are retained. That also means
you don't have to unlink the text fields (unless you want to do that for
other reasons).

--
Regards,
Jay Freedman
Microsoft Word MVP        Word MVP FAQ site: http://www.mvps.org/word

Quote:

> Hi.  I have set up a Word template that has various text
> fields as well as some checkbox fields.  After someone
> fills out the template, a second person needs to run a
> macro that unprotects the document and unhides a hidden
> table within the template and the reprotects the
> document.  However, when they unprotect and reprotect the
> document, all of the data the original person entered into
> the field is deleted.  I have been able to keep the text
> fields on the other 2 tables in the document from losing
> their values but have not been able to maintain the
> checkbox values.  HOw can UI do that?

> Here is the code I am using to maintain the text box
> values just prio to re-prtecting the document:
> ActiveDocument.Range.Tables(1).Select
>     Selection.Fields.Unlink
> ActiveDocument.Range.Tables(2).Select
>     Selection.Fields.Unlink



Sat, 12 Feb 2005 23:36:07 GMT  
 Maitaining form field info when unprotecting and reprotecting a document
Thanks, Jay.  This is exactly what I was hoping to hear.  
It worked perfectly!
Quote:
>-----Original Message-----
>Hi, Chris,

>The .Protect method takes parameters, one of which is
NoReset.

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

>If you omit NoReset from the command, its default value
is False,
>meaning that the original values are lost when

reprotecting. When you
Quote:
>specifically say NoReset:=True the values are retained.
That also means
>you don't have to unlink the text fields (unless you want
to do that for
>other reasons).

>--
>Regards,
>Jay Freedman
>Microsoft Word MVP        Word MVP FAQ site:

http://www.mvps.org/word
Quote:


>> Hi.  I have set up a Word template that has various text
>> fields as well as some checkbox fields.  After someone
>> fills out the template, a second person needs to run a
>> macro that unprotects the document and unhides a hidden
>> table within the template and the reprotects the
>> document.  However, when they unprotect and reprotect
the
>> document, all of the data the original person entered
into
>> the field is deleted.  I have been able to keep the text
>> fields on the other 2 tables in the document from losing
>> their values but have not been able to maintain the
>> checkbox values.  HOw can UI do that?

>> Here is the code I am using to maintain the text box
>> values just prio to re-prtecting the document:
>> ActiveDocument.Range.Tables(1).Select
>>     Selection.Fields.Unlink
>> ActiveDocument.Range.Tables(2).Select
>>     Selection.Fields.Unlink

>.



Mon, 14 Feb 2005 22:36:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem when unprotecting a document with form field text fields

2. Loss of form field text after unprotecting and protecting a form

3. VBA function to manipulate word documents (unprotecting / changing passwords)

4. Protecting and Unprotecting a Section of Document

5. Help - MS WORD and Unprotecting a document

6. Word 6 and unprotecting a document

7. Protecting and Unprotecting a form deletes entries !?!?!

8. use form field to get db info

9. URGENT: Error when assigning long strings to Form Fields in a protected Word document

10. Uning Form Fields and the Track Changes feature in the same document

11. Flashing Documents with FORM Fields

12. Converting text before placing in document (from form field)

 

 
Powered by phpBB® Forum Software