Class MailMerge (Word VBA)

The class MailMerge represents the mail merge functionality in Word.

Class Document gives access to class MailMerge.


Dim mme as MailMerge
Set mme = ActiveDocument.MailMerge

Methods

Check - Simulates the mail merge operation, pausing to report each error as it occurs.

CreateDataSource - Creates a Microsoft Word document that uses a table to store data for a mail merge.

CreateHeaderSource - Creates a Microsoft Word document that stores a header record that is used instead of the data source header record in a mail merge.

EditDataSource - Opens or switches to the mail merge data source.

EditHeaderSource - Opens the header source attached to a mail merge main document, or activates the header source if it is already open.

EditMainDocument - Activates the mail merge main document associated with the specified header source or data source document.

Execute - Performs the specified mail merge operation.

OpenDataSource - Attaches a data source to the specified document, which becomes a main document if it is not one already.

OpenHeaderSource - Attaches a mail merge header source to the specified document.

ShowWizard - Displays the Mail Merge Wizard in a document.

Properties

DataSource returns a MailMergeDataSource object that refers to the data source attached to a mail merge main document.

Destination returns or sets the destination of the mail merge results.

Fields returns a read-only MailMergeFields collection that represents all the mail merge fields in the specified document.

HighlightMergeFields true to highlight the merge fields in a document.

MailAddressFieldName returns or sets the name of the field that contains email addresses that are used when the mail merge destination is electronic mail.

MailAsAttachment true if the merge documents are sent as attachments when the mail merge destination is an email message or a fax.

MailFormat returns a WdMailMergeMailFormat constant that represents the format to use when the mail merge destination is an email message.

MailSubject returns or sets the subject line used when the mail merge destination is electronic mail.

MainDocumentType returns or sets the mail merge main document type.

ShowSendToCustom returns or sets a String corresponding to the caption on a custom button on the Complete the merge step (step six) of the Mail Merge Wizard.

State returns the current state of a mail merge operation.

SuppressBlankLines true if blank lines are suppressed when mail merge fields in a mail merge main document are empty.

ViewMailMergeFieldCodes true if merge field names are displayed in a mail merge main document. False if information from the current record is displayed.

WizardState returns or sets a Long indicating the current Mail Merge Wizard step for a document. The WizardState method returns a number that equates to the current Mail Merge Wizard step; a zero (0) means the Mail Merge Wizard is closed.

MailMergeDataSource - Represents the mail merge data source in a mail merge operation.

MailMergeFields - A collection of MailMergeField objects that represent the mail merge related fields in a document.