AddMergeRec Method

Microsoft Word Visual Basic

Adds a MERGEREC field to a mail merge main document. Returns a MailMergeField object. A MERGEREC field inserts the number of the current data record (the position of the data record in the current query result) during a mail merge.

expression.AddMergeRec(Range)

expression    Required. An expression that returns a MailMergeFields object.

Range    Required Range object. The location for the MERGEREC field.

Example

This example inserts text and a MERGEREC field at the beginning of the active document.

Dim rngTemp As Range

Set rngTemp = ActiveDocument.Range(Start:=0, End:=0)

ActiveDocument.MailMerge.Fields.AddMergeRec Range:=rngTemp
rngTemp.InsertAfter "Record Number: "