MailMergeFields.AddMergeRec method (Word)

Adds a MERGEREC field to a mail merge main document. Returns a MailMergeField object.

Syntax

expression. AddMergeRec( _Range_ )

expression Required. A variable that represents a 'MailMergeFields' collection.

Parameters

Name Required/Optional Data type Description
Range Required Range object The location for the MERGEREC field.

Return value

MailMergeField

Remarks

A MERGEREC field inserts the number of the current record (the position of the record in the current query result) during a mail merge.

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: "

See also

MailMergeFields Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.