如果为 True,Microsoft Word 会标记邮件合并数据源(如果该数据源包含地址域中无效的数据)中的记录。Boolean 类型,可读写。
expression.InvalidAddress
expression 必需。该表达式返回一个 MailMergeDataSource 对象。
使用 SetAllErrorFlags 方法可设置数据源中所有记录的 InvalidAddress 和 InvalidComments 属性。
本示例循环查看邮件合并数据源中的记录,检查邮政编码域包含的数字(本例中域包含六位数字)是否少于五位数字。如果某记录包含少于五位数字的邮政编码,则从邮件合并中排除该记录,并将该地址标记为无效。
Sub ExcludeRecords()
Dim intCount As Integer
On Error Resume Next
With ActiveDocument.MailMerge.DataSource
.ActiveRecord = wdFirstRecord
Do
intCount = intCount + 1
'Counts the number of digits in the postal code field and if
'it is less than 5, the record is excluded from the mail merge,
'marked as having an invalid address, and given a comment
'describing why the postal code was removed
If Len(.DataFields(6).Value) < 5 Then
.Included = False
.InvalidAddress = True
.InvalidComments = "The zip code for this record" & _
"is less than five digits. This record is" & _
"removed from the mail merge process."
End If
.ActiveRecord = wdNextRecord
Loop Until intCount >= .ActiveRecord
End With
End Sub