MailMergeDataSource.ActiveRecord-Eigenschaft (Publisher)

Zurückgeben oder Festlegen einer Long, der den aktiven Seriendruck-Datensatz darstellt. Lese-/Schreibzugriff.

Syntax

Ausdruck. ActiveRecord

Ausdruck Eine Variable, die ein MailMergeDataSource-Objekt darstellt.

Rückgabewert

Long

HinwBemerkungeneise

Die aktive Datensatznummer stellt die Position des Datensatzes im Abfrageergebnis dar, das mithilfe der aktuellen Abfrageoptionen erstellt wurde. Es handelt sich hierbei nicht unbedingt um die Position des Datensatzes in der Datenquelle.

Beispiel

Bei diesem Beispiel wird überprüft, ob der im Feld PostalCode eingegebene Wert 10 Zeichen lang ist. Ist dies nicht der Fall, wird der Datensatz vom Seriendruck ausgeschlossen und mit einem entsprechenden Kommentar versehen.

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

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.