MailMergeFields.AddIf Method
Adds an IF field to a mail merge main document. Returns a MailMergeField object.
Namespace: Microsoft.Office.Interop.Word
Assembly: Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)
Syntax
'Declaration
Function AddIf ( _
Range As Range, _
MergeField As String, _
Comparison As WdMailMergeComparison, _
ByRef CompareTo As Object, _
ByRef TrueAutoText As Object, _
ByRef TrueText As Object, _
ByRef FalseAutoText As Object, _
ByRef FalseText As Object _
) As MailMergeField
'Usage
Dim instance As MailMergeFields
Dim Range As Range
Dim MergeField As String
Dim Comparison As WdMailMergeComparison
Dim CompareTo As Object
Dim TrueAutoText As Object
Dim TrueText As Object
Dim FalseAutoText As Object
Dim FalseText As Object
Dim returnValue As MailMergeField
returnValue = instance.AddIf(Range, MergeField, _
Comparison, CompareTo, TrueAutoText, _
TrueText, FalseAutoText, FalseText)
MailMergeField AddIf(
Range Range,
string MergeField,
WdMailMergeComparison Comparison,
ref Object CompareTo,
ref Object TrueAutoText,
ref Object TrueText,
ref Object FalseAutoText,
ref Object FalseText
)
Parameters
- Range
Type: Microsoft.Office.Interop.Word.Range
Required Range object. The location for the IF field.
- MergeField
Type: System.String
Required String. The merge field name.
- Comparison
Type: Microsoft.Office.Interop.Word.WdMailMergeComparison
Required WdMailMergeComparison. The operator used in the comparison.
- CompareTo
Type: System.Object%
Optional Object. The text to compare with the contents of MergeField.
- TrueAutoText
Type: System.Object%
Optional Object. The AutoText entry that's inserted if the comparison is true. If this argument is specified, TrueText is ignored.
- TrueText
Type: System.Object%
Optional Object. The text that's inserted if the comparison is true.
- FalseAutoText
Type: System.Object%
Optional Object. The AutoText entry that's inserted if the comparison is false. If this argument is specified, FalseText is ignored.
- FalseText
Type: System.Object%
Optional Object. The text that's inserted if the comparison is false.
Return Value
Type: Microsoft.Office.Interop.Word.MailMergeField
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.