Skip to content

Updating Word fields in Documents Created from Access Mergee

How to update Word fields in documents created from Access Mergee.

Q:  Richard Lally writes:  I am very interested in trying the Mail Merge method you suggest but I am anxious about one thing.  The templates include a number of fields that need updating when a document is created from them. I would normally force them to be updated using an AutoNew Word macro. I am, perhaps needlessly, uncomfortable about running Word macros in a document under Access VBA control. What do you recommend? (Note: one of the main uses of fields is to do INCLUDETEXTS to include standard texts used in several templates).

A:  I always include the following code after creating a new Word doc from a template that includes DocProperty fields (it is the equivalent of doing a Select All and Update Fields manually):

      With pappWord

         .Selection.WholeStory

         .Selection.Fields.Update

         .Selection.HomeKey Unit:=wdStory

         .ActiveDocument.SaveAs strSaveName

      End With

 

(For mail merge docs, you wouldn’t need the SaveAs line.)  This should take care of updating any fields that need updating.

BTW, you can use the Document_New event instead of an old AutoNew Word macro.  Document events have been available since Office 2000, I think, though many folks don’t know about them.  The Document events are located in the This Document module in the Microsoft Word Objects folder in the template or document’s project tree in the VB window.

About this author