Publisher) (MailMergeDataSource.InvalidComments 屬性
如果 InvalidAddress 屬性為 True ,則此屬性會傳回或設定說明無效的資料合併記錄的 字串 。 讀取/寫入。
語法
運算式。InvalidComments
表達 代表 MailMergeDataSource 物件的 變數。
傳回值
字串
註解
請使用 SetAllErrorFlags 方法來設定資料來源中的所有記錄的 InvalidAddress 和 InvalidComments 屬性。
範例
本範例搜尋所有記錄,以確定每筆記錄中 PostalCode 欄位的長度至少是五位數。 如果不是,該記錄會從合併列印中排除,並標示為無效。
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
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。