I have a template that uses a userform to collect data, and formfields for
easy completion. After completion, I want to unlink the fields to convert the
whole doc into regular text. The formtext text boxes lose their data, but the
formdropdowns don't. I'm not turning formfield protection on or off. Is
something triggering a reset?
Private Sub cmdFinish_Click()
Call FillVars '(resets vars to form.control.values)
Call FillCustomDocProperties '(sets customDocProperties to vars)
Call UpdateFields '(fields.update, w/headers/footers, like 'unlink' code
below)
With ActiveDocument
.Save
.Fields.Unlink
If .Sections.Count >= 1 Then
For I = 1 To .Sections.Count
.Sections(I).Headers(wdHeaderFooterPrimary).Range.Fields.Unlink
.Sections(I).Headers(wdHeaderFooterFirstPage).Range.Fields.Unlink
.Sections(I).Footers(wdHeaderFooterPrimary).Range.Fields.Unlink
.Sections(I).Footers(wdHeaderFooterFirstPage).Range.Fields.Unlink
Next I
End If
.Save
End With
Thank you.
Jezebel - 01 Nov 2004 23:55 GMT
Are you updating the fields before unlinking them? Anyway, here is better
code for updating and unlinking all fields in a document, wherever they may
be located --
Dim pRange as Word.Range
For each pRange in ActiveDocument.StoryRanges
Do
With pRange.Fields
.Update
.Unlink
End with
set pRange = pRange.NextStoryRange
Loop until pRange is nothing
Next
> I have a template that uses a userform to collect data, and formfields for
> easy completion. After completion, I want to unlink the fields to convert the
[quoted text clipped - 28 lines]
>
> Thank you.
David - 02 Nov 2004 22:59 GMT
Thank you, it does seem a lot better.
I am updating the fields before unlinking them.
I still don't know what is causing me to lose my text.
Thank you