ActiveRecord Property

Microsoft Word Visual Basic

Returns or sets the active mail merge data record. Can be either a valid data record number in the query result or one of the following read/write WdMailMergeActiveRecord constants.

WdMailMergeActiveRecord can be one of these WdMailMergeActiveRecord constants.
wdLastRecord
wdNoActiveRecord
wdFirstRecord
wdNextRecord
wdPreviousRecord

Note  The active data record number is the position of the record in the query result produced by the current query options; as such, this number isn't necessarily the position of the record in the data source.

Example

This example hides the mail merge field codes in the active document so that the merge data is visible in the main document. The active record is then advanced to the next record in the data source.

If ActiveDocument.MailMerge.MainDocumentType <> _
        wdNotAMergeDocument Then 
    With ActiveDocument.MailMerge
        .ViewMailMergeFieldCodes = False
        .DataSource.ActiveRecord = wdNextRecord
    End With
End If
		

This example returns the numerical position of the active data record from Main2.doc.

Dim intRecordNumber as Integer

If Documents("Main2.doc").MailMerge.State = _
        wdMainAndDataSource Or _
        wdMainAndSourceAndHeader Then
    intRecordNumber = Documents("Main2.doc").MailMerge _
        .DataSource.ActiveRecord
End If