MailMergeFields Collection Object
Description
A collection of MailMergeField objects that represent the mail merge related fields in a document.
Using the MailMergeFields Collection
Use the Fields property to return the MailMergeFields collection. The following example adds an ASK field after the last mail merge field in the active document.
Set myMMFields = ActiveDocument.MailMerge.Fields
myMMFields(myMMFields.Count).Select
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdMove
ActiveDocument.MailMerge.Fields.AddAsk Range:=Selection.Range, _
Name:="Name", Prompt:="Type your name", AskOnce:=True
Use the Add method to add a merge field to the MailMergeFields collection. The following example replaces the selection with a MiddleInitial merge field.
ActiveDocument.MailMerge.Fields.Add Range:=Selection.Range, _
Name:="MiddleInitial"
Use Fields(index), where index is the index number, to return a single MailMergeField object. The following example displays the field code of the first mail merge field in the active document.
MsgBox ActiveDocument.MailMerge.Fields(1).Code
Remarks
The MailMergeFields collection has additional methods, such as AddAsk and AddFillIn, for adding fields related to a mail merge operation.
Properties
Application property, Count property, Creator property, Parent property.
Methods
Add method (MailMergeFields collection), AddAsk method, AddFillIn method, AddIf method, AddMergeRec method, AddMergeSeq method, AddNext method, AddNextIf method, AddSet method, AddSkipIf method, Item method.
See Also
Fields collection object.