MailMergeDataSource.Included-Eigenschaft (Word)

True, Wenn ein Datensatz in einem Seriendruck enthalten ist. Boolescher Wert mit Lese-/Schreibzugriff.

Syntax

Ausdruck. Included

Ausdruck Ein Ausdruck, der ein "MailMergeDataSource"-Objekt zurückgibt.

HinwBemerkungeneise

Verwenden Sie die SetAllIncludedFlags-Methode , um alle Datensätze in einer Seriendruck-Datenquelle einzu- oder auszuschließen.

Beispiel

In diesem Beispiel wird für alle Datensätze in der Serienbrief-Datenquelle überprüft, ob das Feld für die Postleitzahl (hier Feld 6) weniger als fünf Ziffern enthält. Wenn ein Datensatz eine Postleitzahl enthält, die aus weniger als fünf Ziffern besteht, wird der Datensatz nicht für die Serienbrieferstellung verwendet und die Adresse als ungültig markiert.

Sub CheckRecords() 
 
 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 = wdFirstRecord 
 Do 
 intCount = intCount + 1 
 
 'Set the condition that field six must be greater than 
 'or equal to five 
 If Len(.DataFields(6).Value) < 5 Then 
 
 'Exclude the record if field six is less than five 
 .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 " & _ 
 "has fewer than five digits. It will be removed " _ 
 & "from the mail merge process." 
 
 End If 
 
 'Move the record to the next record in the data source 
 .ActiveRecord = wdNextRecord 
 
 'End the loop when the counter variable equals the 
 'number of records in the data source 
 Loop Until intCount = .RecordCount 
 End With 
 
End Sub

Siehe auch

MailMergeDataSource-Objekt

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.