AddSkipIf Method
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.
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.
WdMailMergeComparison
WdMailMergeComparison can be one of these WdMailMergeComparison constants. |
wdMergeIfEqual |
wdMergeIfGreaterThanOrEqual |
wdMergeIfIsNotBlank |
wdMergeIfLessThanOrEqual |
wdMergeIfGreaterThan |
wdMergeIfIsBlank |
wdMergeIfLessThan |
wdMergeIfNotEqual |
CompareTo Optional Variant. The text to compare with the contents of MergeField.
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.
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"
Applies to | MailMergeFields Collection Object
See Also | AddIf Method | AddNextIf Method