Share via


MailMerge Object

MailMerge Object
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Document
Aa679565.parchild(en-us,office.10).gifMailMerge
Aa679565.space(en-us,office.10).gifAa679565.parchild(en-us,office.10).gif

Represents the mail merge functionality in Word.

Using the MailMerge Object

Use the MailMerge property to return the MailMerge object. The MailMerge object is always available regardless of whether the mail merge operation has begun. Use the State property to determine the status of the mail merge operation. The following example executes a mail merge if the active document is a main document with an attached data source.

  If ActiveDocument.MailMerge.State = wdMainAndDataSource Then
    ActiveDocument.MailMerge.Execute
End If

The following example merges the main document with the first three data records in the attached data source and then sends the results to the printer.

  Set myMerge = ActiveDocument.MailMerge
If myMerge.State = wdMainAndSourceAndHeader Or _
    myMerge.State = wdMainAndDataSource Then
    With myMerge.DataSource
        .FirstRecord = 1
        .LastRecord = 3
    End With
End If
With myMerge
    .Destination = wdSendToPrinter
    .Execute
End With