Application.MailMergeDataSourceValidate Event
Publisher Developer Reference |
Occurs when a user performs address verification by clicking Validate in the Mail Merge Recipients dialog box.
Syntax
expression.MailMergeDataSourceValidate(Doc, Handled)
expression A variable that represents an Application object.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
Doc | Required | Document | The mail merge main document. |
Handled | Required | Boolean | True runs the accompanying validation code against the mail merge data source. False cancels the data source validation. |
Remarks
If you do not have address verification software installed on your computer, use the MailMergeDataSourceValidate event to create simple filtering routines, such as looping through records to check the postal codes and remove any that are non-U.S. Non-U.S. users can filter out all U.S. postal codes by modifying the code sample below and using Microsoft Visual Basic commands to search for text or special characters.
To access the Application object events, declare an Application object variable in the General Declarations section of a code module. Then set the variable equal to the Application object for which you want to access events. For information about using events with the Microsoft Office Publisher Application object, see Using Events with the Application Object.
Example
This example validates ZIP Codes in the attached data source for five digits. If the length of the ZIP Code is fewer than five digits, the record is excluded from the mail merge process. This example assumes the postal codes are U.S. ZIP Codes. You could modify this example to search for ZIP Codes that have a four-digit locator code appended to the ZIP Code, and then exclude all records that do not contain the locator code.
Visual Basic for Applications |
---|
|
For this event to occur, you must place the following line of code in the General Declarations section of your module and run the following initialization routine.
Visual Basic for Applications |
---|
|
See Also