Compartilhar via


MailMergeFields.AddSkipIf Method

Word Developer Reference

Adds a SKIPIF field to a mail merge main document. Returns a MailMergeField object. .

Syntax

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

expression   Required. A variable that represents a MailMergeFields collection.

Parameters

Name Required/Optional Data Type Description
Range Required Range object The location for the SKIPIF field.
MergeField Required String The merge field name.
Comparison Required WdMailMergeComparison The operator used in the comparison.
CompareTo Optional Variant The text to compare with the contents of MergeField.

Return Value
MailMergeField

Remarks

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

Example

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

Visual Basic for Applications
  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"

See Also