Share via


MailMergeDataSource.ApplyFilter Method

Publisher Developer Reference

Applies a filter to a mail merge data source to remove (or filter out) specified records containing (or not containing) specific data.

Syntax

expression.ApplyFilter

expression   A variable that represents a MailMergeDataSource object.

Example

This example adds a new filter that removes all records with a blank Region field and then applies the filter to the active publication. This example assumes that a mail merge data source is attached to the active publication.

Visual Basic for Applications
  Sub FilterDataSource()
    With ActiveDocument.MailMerge.DataSource
        .Filters.Add Column:="Region", _
            Comparison:=msoFilterComparisonIsBlank, _
            Conjunction:=msoFilterConjunctionAnd
        .ApplyFilter
    End With
End Sub

See Also