共用方式為


Publisher) (MailMergeDataSource.ActiveRecord 屬性

會傳回或設定 Long ,代表使用中合併記錄。 讀取/寫入。

語法

運算式ActiveRecord

表達 代表 MailMergeDataSource 物件的 變數。

傳回值

Long

註解

使用中資料記錄編號是此記錄在根據目前查詢選項所產生之查詢結果中的位置;因此這個資料記錄編號未必是記錄在資料來源中的位置。

範例

本範例會驗證輸入至 PostalCode 欄位的值長度為 10 個字元, (美國郵遞區號加上 4 位數的定位器代碼) 。 如果不是,則會從合併列印中排除並標示批註。

Sub ValidateZip() 
 
 Dim intCount As Integer 
 
 On Error Resume Next 
 
 With ActiveDocument.MailMerge.DataSource 
 
 'Set the active record equal to the first included 
 'record in the data source 
 .ActiveRecord = 1 
 Do 
 intCount = intCount + 1 
 
 'Set the condition that the PostalCode field 
 'must be greater than or equal to ten digits 
 If Len(.DataFields.Item("PostalCode").Value) < 10 Then 
 
 'Exclude the record if the PostalCode field 
 'is less than ten digits 
 .Included = False 
 
 'Mark the record as containing an invalid address field 
 .InvalidAddress = True 
 
 'Specify the comment attached to the record explaining 
 'why the record was excluded from the mail merge 
 .InvalidComments = "The ZIP Code for this record is " _ 
 & "less than ten digits. It will be removed " _ 
 & "from the mail merge process." 
 
 End If 
 
 'Move the record to the next record in the data source 
 .ActiveRecord = .ActiveRecord + 1 
 
 'End the loop when the counter variable 
 'equals the number of records in the data source 
 Loop Until intCount = .RecordCount 
 End With 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應