邮件合并对象 (Word)MailMerge object (Word)

代表 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 对象模型参考Word Object Model Reference

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.