Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 1.36 KB

Word.MailMerge.md

File metadata and controls

57 lines (38 loc) · 1.36 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
MailMerge object (Word)
vbawd10.chm2336
vbawd10.chm2336
Word.MailMerge
b228c4d6-9ca7-8795-12f6-d32e62844a83
06/08/2017
medium

MailMerge object (Word)

Represents the mail merge functionality in Word.

Remarks

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

See also

Word Object Model Reference

[!includeSupport and feedback]