MailMergeFields.AddSkipIf method (Word)

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.

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

MailMergeFields Collection Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.