SetAllErrorFlags Method

Microsoft Word Visual Basic

expression.SetAllErrorFlags(Invalid, InvalidComment)

expression    Required. An expression that returns a MailMergeDataSource object.

Invalid   Required Boolean. True marks all records in the data source of a mail merge as invalid.

InvalidComment   Required String. Text describing the invalid setting.

Remarks

You can individually mark data source records that contain invalid data in an address field by using the InvalidAddress and InvalidComments properties.

Example

This example marks all records in the data source as containing an invalid address field, sets a comment as to why it is invalid, and excludes all records from the mail merge.

Sub FlagAllRecords()
    With ActiveDocument.MailMerge.DataSource
        .SetAllErrorFlags Invalid:=True, InvalidComment:= _
            "All records in the data source have only 5-" _
            & "digit zip codes.  Need 5+4 digit zip codes."
        .SetAllIncludedFlags Included:=False
    End With
End Sub