MailMergeFields.AddNextIf (Word)
Adds a NEXTIF field to a mail merge main document. Returns a MailMergeField object.
A NEXTIF field compares two expressions, and if the comparison is true, the next record is merged into the current merge document.
AddNextIf (Range, MergeField, Comparison, CompareTo)
Documents("Main.doc").MailMerge.Fields(1).Select
Selection.Collapse Direction:=wdCollapseStart
Documents("Main.doc").MailMerge.Fields.AddNextIf _
Range:=Selection.Range, MergeField:="PostalCode", _
Comparison:=wdMergeIfEqual, CompareTo:="98004"
Arguments
The following arguments are required:
Range (Range) - The location for the NEXTIF field.
MergeField (String) - The merge field name.
Comparison (WdMailMergeComparison) - The operator used in the comparison.
Possible values are
| wdMergeIfEqual | A value is output if the mail merge field is equal to a value. |
| wdMergeIfGreaterThan | A value is output if the mail merge field is greater than a value. |
| wdMergeIfGreaterThanOrEqual | A value is output if the mail merge field is greater than or equal to a value. |
| wdMergeIfIsBlank | A value is output if the mail merge field is blank. |
| wdMergeIfIsNotBlank | A value is output if the mail merge field is not blank. |
| wdMergeIfLessThan | A value is output if the mail merge field is less than a value. |
| wdMergeIfLessThanOrEqual | A value is output if the mail merge field is less than or equal to a value. |
| wdMergeIfNotEqual | A value is output if the mail merge field is not equal to a value. |
Optional arguments
The following argument is optional
CompareTo (String) - The text to compare with the contents of MergeField.