Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

MailMergeDataSource.Included Property

Office 2007
True if a record is included in a mail merge. Read/write Boolean.

Syntax

expression.Included

expression   A variable that represents an MailMergeDataSource object.

Return Value
Boolean

Remarks

Use the SetAllIncludedFlags method to set the included status for all mail merge records.

Example

This example searches the records to verify that the length of the PostalCode field for each record is at least five digits long. If it is not, the record is excluded from the mail merge and flagged as invalid.

Visual Basic for Applications
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



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.