MailMergeFilterCriterion.Comparison Property (Publisher)

Returns or sets an MsoFilterComparison constant that represents how to compare the Column and CompareTo properties. Read/write.


expression. Comparison

expression A variable that represents a MailMergeFilterCriterion object.

Return Value



The Comparison property value can be one of the ** MsoFilterComparison** constants declared in the Microsoft Office type library.


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 mail merge 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 intItem 
 End With 
End Sub