Share via


MailMerge.Execute Method

Publisher Developer Reference

Performs the specified mail merge or catalog merge operation. Returns a Document object that represents the new or existing publication specified as the destination of the merge results. Returns Nothing if the merge is executed to a printer.

Syntax

expression.Execute(Pause, Destination, Filename)

expression   A variable that represents a MailMerge object.

Parameters

Name Required/Optional Data Type Description
Pause Required Boolean True to have Microsoft Office Publisher pause and display a troubleshooting dialog box if a merge error is found. False to ignore errors during mail merge or catalog merge.
Destination Optional PbMailMergeDestination The destination of the mail merge or catalog merge results. Specifying pbSendToPrinter for a catalog merge results in a run-time error.
Filename Optional String The file name of the publication to which you want to append the catalog merge results.

Return Value
Document

Remarks

Destination can be one of these PbMailMergeDestination constants. The default is pbSendToPrinter.

pbSendToPrinter

pbMergeToNewPublication

pbMergeToExistingPublication

Example

This example executes a mail merge if the active publication is a main document with an attached data source.

Visual Basic for Applications
  Sub ExecuteMerge()
    Dim mrgDocument As MailMerge
    Set mrgDocument = ActiveDocument.MailMerge
    If mrgDocument.DataSource.ConnectString <> "" Then
        mrgDocument.Execute Pause:=False
    End If
End Sub

See Also