Edit

Share via


MailMergeFields.AddIf Method

Definition

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

public Microsoft.Office.Interop.Word.MailMergeField AddIf (Microsoft.Office.Interop.Word.Range Range, string MergeField, Microsoft.Office.Interop.Word.WdMailMergeComparison Comparison, ref object CompareTo, ref object TrueAutoText, ref object TrueText, ref object FalseAutoText, ref object FalseText);
abstract member AddIf : Microsoft.Office.Interop.Word.Range * string * Microsoft.Office.Interop.Word.WdMailMergeComparison * obj * obj * obj * obj * obj -> Microsoft.Office.Interop.Word.MailMergeField
Public Function AddIf (Range As Range, MergeField As String, Comparison As WdMailMergeComparison, Optional ByRef CompareTo As Object, Optional ByRef TrueAutoText As Object, Optional ByRef TrueText As Object, Optional ByRef FalseAutoText As Object, Optional ByRef FalseText As Object) As MailMergeField

Parameters

Range
Range

Required Range object. The location for the IF field.

MergeField
String

Required String. The merge field name.

Comparison
WdMailMergeComparison

Required WdMailMergeComparison. The operator used in the comparison.

CompareTo
Object

Optional Object. The text to compare with the contents of MergeField.

TrueAutoText
Object

Optional Object. The AutoText entry that's inserted if the comparison is true. If this argument is specified, TrueText is ignored.

TrueText
Object

Optional Object. The text that's inserted if the comparison is true.

FalseAutoText
Object

Optional Object. The AutoText entry that's inserted if the comparison is false. If this argument is specified, FalseText is ignored.

FalseText
Object

Optional Object. The text that's inserted if the comparison is false.

Returns

Remarks

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.

Applies to