Application.MailMergeInsertBarcode event (Publisher)

Occurs when the user issues the command to insert postal barcodes into a mail-merge publication, either in the Microsoft Publisher user interface (UI), or programmatically.

Syntax

expression.MailMergeInsertBarcode (Doc, OkToInsert)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Doc Required Document The current publication.
OkToInsert Required Boolean Output parameter. True if it is okay to insert barcodes.

Remarks

Use the TextRange.InsertBarcode method to insert barcodes into a mail merge publication.

Third-party add-ins that validate mail-merge addresses can use the MailMergeInsertBarcode event to listen for user actions requesting that barcodes be inserted. In this situation, when the add-in receives notification that the MailMergeInsertBarcode event fired, it checks the validity of the addresses in the mail-merge list, and if the addresses are valid, it attempts to generate barcodes. If this attempt is successful, the add-in should return True for the OkToInsert parameter. If the attempt fails, the add-in should return False.

Actual barcode data is provided to Publisher by the MailMergeGenerateBarcode event.

The MailMergeInsertBarcode event is also triggered when a user chooses Add a postal barcode in the Mail Merge or Catalog Merge task pane, or Add postal bar codes in the Publisher Tasks task pane in the Publisher UI. Before a user can choose either of these UI commands, you must first make them available by setting the InsertBarcodeVisible property to True.

For more information about using events with the Application object, see Using events with the Application object.

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to handle the MailMergeInsertBarcode event. It displays a message asking whether to proceed with inserting barcodes.

Private Sub pubApplication_MailMergeInsertBarcode(ByVal Doc As Document, OkToInsert As Boolean) 
 
 Dim intResponse As Integer 
 
 intResponse = MsgBox("Proceed to insert barcodes?", vbYesNo) 
 
 If intResponse = vbYes Then OkToInsert = True 
 
End Sub

For this event to occur, you must place the following line of code in the General Declarations section of your module.

Public WithEvents pubApplication As Application

You then must run the following initialization procedure.

Public Sub Initialize_pubApplication() 
 Set pubApplication = Publisher.Application 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.