MailMergeDataSource.InvalidAddress property (Publisher)

True to mark a record in a mail merge data source if it contains invalid data. Read/write Boolean.

Syntax

expression.InvalidAddress

expression A variable that represents a MailMergeDataSource object.

Return value

Boolean

Remarks

Use the SetAllErrorFlags method to set both the InvalidAddress and InvalidComments properties for all records in a data source.

Example

This example searches the records to verify that the length of the PostalCode field for each record is at least five digits long. If it is not, the record is excluded from the mail merge and flagged as invalid.

Sub ExcludeRecords() 
 Dim intRecord As Integer 
 With ActiveDocument.MailMerge 
 For intRecord = 1 To .DataSource.RecordCount 
 .DataSource.ActiveRecord = intRecord 
 If Len(.DataSource.DataFields("PostalCode").Value) < 5 Then 
 With .DataSource 
 .Included = False 
 .InvalidAddress = True 
 .InvalidComments = "This record is removed " & _ 
 "from the mail merge because its postal code" & _ 
 "has less than five digits." 
 End With 
 End If 
 Next 
 End With 
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.