Execute Method

Microsoft Publisher Visual Basic

Show All Show All

Execute Method

ShowAs it applies to the FindReplace object.

Performs the specified Find or Replace operation.

expression.Execute

expression    Required. An expression that returns a FindReplace object.

Note  Be sure to set the FindText property before calling the Execute method to avoid a run time error.

ShowAs it applies to the MailMerge object.

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.

expression.Execute(Pause, Destination, Filename)

expression    Required. An expression that returns a MailMerge object.

Pause   Required Boolean. True to have 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.

PbMailMergeDestination can be one of these PbMailMergeDestination constants.
pbSendToPrinter Default
pbMergeToNewPublication
pbMergeToExistingPublication

Filename   Optional String. The file name of the publication to which you want to append the catalog merge results.

Example

ShowAs it applies to the FindReplace object.

This example executes a Find and Replace operation on the active document.

Sub ExecuteFindReplace()
    Dim objFindReplace As FindReplace
    Set objFindReplace = ActiveDocument.Find
    With objFindReplace
        .Clear
        .FindText = "library"
        .Execute
    End With
End Sub

		

ShowAs it applies to the MailMerge object.

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

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