Table of contents
TOC
Collapse the table of content
Expand the table of content

MailMergeFilterCriterion Object (Publisher)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Represents a filter to be applied to an attached mail merge or catalog merge data source. The MailMergeFilterCriterion object is a member of the MailMergeFilters object.

Example

Each filter is a line in a query string. Use the Column, Comparison, CompareTo, and Conjunction properties to return or set the data source query criterion. The following example changes an existing filter to remove from the mail merge all records that do not have a Region field equal to "WA". This example assumes that a data source is attached to the active publication.

Sub SetQueryCriterion() 
 Dim intItem As Integer 
 With ActiveDocument.MailMerge.DataSource.Filters 
 For intItem = 1 To .Count 
 With .Item(intItem) 
 If .Column = "Region" Then 
 .Comparison = msoFilterComparisonNotEqual 
 .CompareTo = "WA" 
 If .Conjunction = "Or" Then .Conjunction = "And" 
 End If 
 End With 
 Next 
 End With 
End Sub

Use the Add method of the MailMergeFilters object to add a new filter criterion to the query. This example adds a new line to the query string and then applies the combined filter to the data source. This example assumes that a data source is attached to the active publication.

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

Properties

Name
Application
Column
CompareTo
Comparison
Conjunction
Creator
Index
Parent
© 2017 Microsoft