Table of contents
Collapse the table of content
Expand the table of content

MailMergeDataSource.InvalidComments Property (Publisher)

office 365 dev account|Last Updated: 8/24/2017
3 Contributors

If the InvalidAddress property is True, this property returns or sets a String that describes invalid data in a mail merge record. Read/write.


expression. InvalidComments

_expression_A variable that represents an MailMergeDataSource object.

Return Value



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


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 
 End With 
End Sub
© 2018 Microsoft