AddSkipIf Method

Applies To

MailMergeFields collection object.

Description

Adds a SKIPIF field to a mail merge main document. Returns a MailMergeField object. A SKIPIF field compares two expressions, and if the comparison is true, SKIPIF moves to the next data record in the data source and starts a new merge document.

Syntax

expression.AddSkipIf(Range, MergeField, Comparison, CompareTo)

expression Required. An expression that returns a MailMergeFields object.

Range Required Range object. The location for the SKIPIF field.

MergeField Required String. The merge field name.

Comparison Required Long. The operator used in the comparison. Can be one of the following WdMailMergeComparison constants: wdMergeIfEqual, wdMergeIfGreaterThan, wdMergeIfGreaterThanOrEqual, wdMergeIfIsBlank, wdMergeIfIsNotBlank, wdMergeIfLessThan, wdMergeIfLessThanOrEqual, or wdMergeIfNotEqual.

CompareTo Optional Variant. The text to compare with the contents of MergeField.

See Also

AddIf method, AddNextIf method.

Example

This example adds a SKIPIF field before the first MERGEFIELD field in Main.doc. If the next postal code equals 98040, the next data record is skipped and a new merge document is created.

Documents("Main.doc").MailMerge.Fields(1).Select
Selection.Collapse Direction:=wdCollapseStart
Documents("Main.doc").MailMerge.Fields.AddSkipIf _
    Range:=Selection.Range, MergeField:="PostalCode", _
    Comparison:=wdMergeIfEqual, CompareTo:="98040"