Adds an IF field to a mail merge main document. Returns a MailMergeField object. When updated, an IF field compares a field in a data record with a specified value, and then it inserts the appropriate text according to the result of the comparison.
Syntax
expression.AddIf(Range, MergeField, Comparison, CompareTo, TrueAutoText, TrueText, FalseAutoText, FalseText)
expression Required. An expression that returns a MailMergeFields object.
Range Required Range object. The location for the IF 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.
TrueAutoText Optional Variant. The AutoText entry that's inserted if the comparison is true. If this argument is specified, TrueText is ignored.
TrueText Optional Variant. The text that's inserted if the comparison is true.
FalseAutoText Optional Variant. The AutoText entry that's inserted if the comparison is false. If this argument is specified, FalseText is ignored.
FalseText Optional Variant. The text that's inserted if the comparison is false.