Note that if you have any Ref or calculation fields that rely on your
formfields they will be changed when you insert the AutoText entry which
will redefine the bookmarks. If this is the case, you may need to select
your entire document (or at least the current page) and either lock or
unlink the fields. (This would be done while the document is unprotected.)
The following amendment does this (but unlinks all fields in the body of the
document). The poster may need something that only targets particular fields
but this is quick and dirty and works. It is only necessary if the
information in a form field is used in another field.
Sub InsertAutoTextInForm()
Dim doc As Word.Document
Dim rng As Word.Range
Set doc = ActiveDocument
Set rng = doc.Range
rng.Collapse wdCollapseEnd
If doc.ProtectionType <> wdNoProtection Then
doc.Unprotect
End If
doc.Fields.Unlink
doc.AttachedTemplate.AutoTextEntries( _
"ATTest").Insert rng, True
doc.Protect wdAllowOnlyFormFields, True
End Sub
The following macro updates only Ref fields. It could be called by the
insertion module prior to insertion of the AutoText and the command could be
changed to unlink.
Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Next oStory
End Sub
If a different kind of field is being used to reflect the data in the
formfields, that field type could be specified instead. I guess one other
change I would make to your (excellent) recommendations would be to change
the paragraph formatting of the first paragraph of the AutoText entry to
page break before rather than inserting a manual page break.
This may be more than the original poster needs or wants. If so, I
apologize.
--
Charles Kenyon
Word New User FAQ & Web Directory:
http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
http://addbalance.com/usersguide
See also the MVP FAQ:
http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.