Word if field example

toolbar and then click If…Then…Else.

Here are some examples of ways to modify the IF field codes by using them in concert with other field codes:

ShowCompare a data field with another data field or bookmark

This IF field compares the number in the Rate data field with the number in the Discount data field. If the numbers are equal, the specified text is printed.

{ IF { MERGEFIELD Rate } = { MERGEFIELD Discount } «We will offer you a larger discount. » » » }

(If number in the Rate data field does not equal the number in the Discount field, no text is printed.)

ShowInsert other Word fields into an IF field

Example 1

If the condition specified by this IF field is met, the INCLUDETEXT field inserts the contents of the indicated document. To specify the location and file name of the included document, use double backslash (\) characters, as shown in the example. If the condition is not met, Word inserts the AutoText entry «Copyright.»

{ IF { MERGEFIELD State } = «NY» «{ INCLUDETEXT c:\worddocs\contract.doc }» «{ AUTOTEXT Copyright }» }

Example 2

If the Company data field for a data record contains any information— that is, if the field is not blank— Word prints text from the CompanyAddress field. Otherwise, Word prints text from the HomeAddress field.

{ IF { MERGEFIELD Company } <> » » «{ MERGEFIELD CompanyAddress }» «{ MERGEFIELD HomeAddress }» }

ShowPerform calculations in an IF field

In this example, the first = (Formula) field in the following example computes the current balance of each account. If a balance remains, the Formula field is repeated to report the current balance. If the computed balance is 0 (zero) or less, Word prints the alternative text, «Your account is paid in full. Thank you.»

{ IF { = { MERGEFIELD Balance }{MERGEFIELD Payment } } > 0 «Your current balance is { = { MERGEFIELD Balance }{ MERGEFIELD Payment } # «$#,##0.00; » }.» «Your account is paid in full. Thank you.» }

ShowSpecify multiple conditions

You can specify multiple conditions by nesting a COMPARE field or another IF field inside an IF field.

Example 1

In this example, COMPARE fields examine the data fields CustomerNumber and CustomerRating as Word merges each data record. The AND function of the = (Formula) field returns a value of «1» (true) if both of the data field values indicate a satisfactory account, in which case Word prints the first text in quotation marks.

{ IF { = AND ( { COMPARE { MERGEFIELD CustomerNumber } >= 4 }, { COMPARE { MERGEFIELD CustomerRating } <= 3 } ) } = 1 «Satisfactory» «Unsatisfactory»}

Example 2

In this example, special rates are offered only to residents of California or Washington. If the State field specifies any other state, no additional text is printed because no alternative text has been specified in the second IF field.

{IF {MERGEFIELD State} = «CA» «For California residents, we offer special rates to Asia and Japan.» «{IF {MERGEFIELD State} = «WA» «For Washington residents, we offer special rates to Asia and Japan.» » «} «}

If Statements / If Fields / Comparison Statements

IF statements (also called IF fields) allow you to compare two values and display document content based on the result of the comparison. When used in a Word template, IF statements are especially useful for comparing the values of Composer merge fields and then displaying the appropriate content.

Example use cases:

  • If an Account’s billing country is not in the United States, display information about international shipping terms. Otherwise, show domestic shipping terms.
  • If a Contact’s mailing address is blank, show the billing address from his related Account. If it’s not blank, show the Contact’s mailing address.
  • If an Opportunity’s amount is greater than $10,000, show information about a complimentary service package. If not, show nothing.

Nested IF statements in Word, where the else value is another IF statement, will work with Conga Composer but are not recommended. Conga Technical Support will not assist with nested IF statements. Conga highly recommends evaluating nested IF statement logic using Salesforce formula fields and then merging the formula field values into the document.

Watch this video on How to Add IF Statements to Templates.

Create IF Statements in a Word Template

IF statements can use Word merge fields or text-based merge fields, with one exception: the IF statement itself must be a Word merge field. This means that all the fields inside or around the IF statement can be either Word or text-based merge fields, but again, the IF statement itself must be a Word merge field.  Following are examples of both types of syntax.

Syntax

{IF "Expression 1" Operator "Expression 2" "TrueValue" "FalseValue"}

Below is a very basic example using Word merge fields as Expressions. The single braces ({ }) on either end of the IF statement indicate the beginning and end of a Word merge field when the field codes have been toggled open.

{IF "{{Opportunity_Amount}}" > "100000 "Big Deal Opptye" "Normal Oppty"}

Components of an IF Field

Expression1 & Expression2:

  • Both Expression1 and Expression2 represent fields and values that you want to compare.
  • Expressions are usually Word or text-based merge fields, text strings, or numbers. Expression1 and Expression2 should be surrounded with quotation marks («»).

Operator

  • A comparison operator. There is always a space before and after the operator.
  • Supported operators:

TrueValue & FalseValue

  • Content that is shown when the comparison is true (TrueValue) or false (FalseValue). Each must be surrounded with quotation marks.

If the content of your TrueValue or FalseValue contains quotation marks ( “ or ” ), you need to replace those quotes with two pairs of single quotation marks (‘’ ‘’ instead of “ ”). Otherwise, Word will consider the first quotation mark from your merged data as the end of your text string and the IF statement will not work.

Creating an IF Field — Conga Best Practices

It is important to follow best practices to ensure the stability and sustainability of your IF statements. In the example below, we will show in detail the best practice method for creating IF statements.  We will also show the syntax for both Word merge field and text-based merge fields.

Example scenario: If the Opportunity Amount is greater than $10,000, show information about a complimentary service package. If it’s not, do not show anything.

We recommend the following approach:

Procedure Step Result
Create a traditional merge field with a placeholder name. «IF_Amount>10000»
Open the merge field by toggling field codes. {MERGEFIELD IF_Amount>10000 * MERGEFORMAT}
Delete the contents of the field, entering IF instead. {IF}
Add Expression1 to the IF field. In our example, Expression1 is the Opportunity Amount field.

Word

{IF “«OPPORTUNITY_AMOUNT»”}

Text-based

{IF “{{OPPORTUNITY_AMOUNT}}”}

Insert your Operator. We’re using greater than (>).

Word

{IF “«OPPORTUNITY_AMOUNT»” >}

Text-based

{IF “{{OPPORTUNITY_AMOUNT}}” >}

Insert Expression2. Our example is $10,000.

Word

{IF “«OPPORTUNITY_AMOUNT»” > “10000”}

Text-based

{IF “{{OPPORTUNITY_AMOUNT}}” >  “10000”}

Insert TrueValue. Our example is a merge field that displays the details of a complimentary service package.

Word

{IF “«OPPORTUNITY_AMOUNT»” > “10000” “«OPPORTUNITY_SERVICE_PACKAGE»”}

Text-based

{IF “{{OPPORTUNITY_AMOUNT}}” > “10000” “{{OPPORTUNITY_SERVICE_PACKAGE}}” }

Insert FalseValue. In our example, we don’t want to display anything if the Opportunity Amount is less than $10,000, so our FalseValue is null.  This is represented by a pair of quotation marks.

Word

{IF “«OPPORTUNITY_AMOUNT»” > “10000” “«OPPORTUNITY_SERVICE_PACKAGE»” “”}

Text-based

{IF “{{OPPORTUNITY_AMOUNT}}” > “10000” “{{OPPORTUNITY_SERVICE_PACKAGE}}”  “”}

Our finished IF field looks like this:

Word
{IF “«OPPORTUNITY_AMOUNT»” > “10000” “«OPPORTUNITY_SERVICE_PACKAGE»” “”}

Text-based
{IF “{{OPPORTUNITY_AMOUNT}}” > “10000” “{{OPPORTUNITY_SERVICE_PACKAGE}}”  “”}

An IF statement that is toggled open should look exactly like the examples above when it is completed.  When initially creating the IF statement, Word will include the following text at the end: * MERGEFORMAT. This text needs to be removed to ensure the IF statement renders consistently.

When we toggle the field codes closed, the IF statement will revert to the Word merge field with the placeholder name:

«IF_Amount > 10000»

Using the IF statement we just created, let’s consider an example:

The Merge Nation Opportunity has an amount of $25,000. Once we merge the Composer template that uses our IF statement, our merged document will look like this:

We are showing the value of the OPPORTUNITY_SERVICE_PACKAGE field since that is our TrueValue.

Now let’s say we use a different Opportunity called Merge Republic, which only has an amount of $8,000. Our merged document will show nothing («»), since that is our FalseValue.

Warnings

  • Checkbox fields: Although the Composer View Data Workbook and the Template Builder show the values of checkbox fields as TRUE and FALSE, those values do not work in an IF statement. Change your value from TRUE to True.
    Example: {IF "<<Checkbox_MergeField>>" = "True" "Yes" "No"}
  • Tables: IF statements placed inside a table row cannot hide the table row when the statement evaluates to show nothing.  You will instead have a blank table row. Word IF statements cannot be used to hide rows within a table.
  • IF statements do not work in a Conga Email template.

Try this…from the MS Office 2003 site…

It looks like if you enclose your dropdown box name in parens, it should work…hope this helped!:cool:

«The IF field (field: A set of codes that instructs Microsoft Word to insert text, graphics, page numbers, and other material into a document automatically. For example, the DATE field inserts the current date.) performs one of two alternative actions, depending on a condition you specify. For example, the statement «If the weather is sunny, we’ll go to the park; if not, we’ll go to the movies» specifies a condition that must be met (sunny weather) for a certain action to take place (going to the park). If the condition is not met, an alternative action occurs (going to the movies).

The following IF field is a similar type of statement. If the current data record (data record: A complete set of related information that corresponds to one row of information in the data source. All information about one client in a client mailing list is an example of a data record.) contains «San Francisco» in the City field, Microsoft Word prints the first text in quotation marks in the merged document that results from that data record. Otherwise, Word prints the second set of text. This example uses the IF and MERGEFIELD fields together.

{ IF { MERGEFIELD City } = «San Francisco» «Please call our local office.» «Please return the enclosed form in the provided envelope.» }

Word inserts an IF field in this form when you click the Insert Word Field button on the Mail Merge toolbar (toolbar: A bar with buttons and options that you use to carry out commands. To display a toolbar, press ALT and then SHIFT+F10.) and then click If…Then…Else.

Here are some examples of ways to modify the IF field codes (field code: Placeholder text that shows where specified information from your data source will appear; the elements in a field that generate a field’s result. The field code includes the field characters, field type, and instructions.) by using them in concert with other field codes:

Compare a data field with another data field or bookmark

This IF field compares the number in the Rate data field (data field: A category of information that corresponds to one column of information in a data source. The name of each data field is listed in the first row (header row) of the data source. «PostalCode» and «LastName» are examples of data field names.) with the number in the Discount data field. If the numbers are equal, the specified text is printed.

{ IF { MERGEFIELD Rate } = { MERGEFIELD Discount } «We will offer you a larger discount. » » » }

(If number in the Rate data field does not equal the number in the Discount field, no text is printed.)

Insert other Word fields into an IF field

Example 1
If the condition specified by this IF field is met, the INCLUDETEXT field inserts the contents of the indicated document. To specify the location and file name of the included document, use double backslash (\) characters, as shown in the example. If the condition is not met, Word inserts the AutoText entry «Copyright.»

{ IF { MERGEFIELD State } = «NY» «{ INCLUDETEXT c:\worddocs\contract.doc }» «{ AUTOTEXT Copyright }» }

Example 2
If the Company data field for a data record contains any information — that is, if the field is not blank — Word prints text from the CompanyAddress field. Otherwise, Word prints text from the HomeAddress field.

{ IF { MERGEFIELD Company } <> » » «{ MERGEFIELD CompanyAddress }» «{ MERGEFIELD HomeAddress }» }»

Conditional Mail Merge in MS Word

Microsoft Word provides basic personalization options for mail merges using merge fields. What if you want to apply more advanced personalization in a Word mail merge (beyond the basic first name/last name changes) or include conditionally formatted content in the merge fields? You can accomplish that with conditional mail merge rules in Microsoft Word.

Unlike Excel, there is no conditional formatting button in Microsoft Word. In addition, when sending out emails, MS Word does not preserve the formatting of MS Excel data files. However, you may employ an IF…THEN…ELSE rule to modify formatting and replace text/paragraphs depending on the conditions you define. Conditional mail merge allows you to change the content of your emails based on specific criteria or variable data in your excel data file, such as gender, client sector, purchase date, and so on.

Conditional mail merge capabilities in Microsoft Word are limited and need strong software expertise to set up. In addition, if you make a small error, you’ll run into a slew of formatting issues.

In this article, we’ll show you how to set up a conditional mail merge in MS Word correctly, as well as the most common mistakes to avoid. We’ll also go through a simple method for hyper-personalizing your emails using GMass.

How to Insert Conditional Content (If…Then…Else) in Word Mail Merge Fields

In Microsoft Word, the IF function is enclosed in curly braces. It begins with a condition and then contains the action to perform if true, as well as the action to take if false, as shown below:

{ IF Condition “Truetext” “Falsetext”}

Examples:

{ IF { MERGEFIELD Gender } = “Male” “Mr.” “Ms. }

{ IF { MERGEFIELD Industry } = “Recruiting” “hope the recruiting business is going well, and you’re placing lots of candidates!” “hope things are going well for you.”}

Note: In Microsoft Word, these curly braces must be placed using an If…then…else rule as shown below. Alternatively, you may use the Ctrl+F9 key combination to add them. The conditional formatting will not work if the curly braces are entered manually.

Here’s how to implement conditional mail merge in MS Word:

1. Open MS Word > Go to Mailings tab

2. Click Start mail merge and choose Letters

3. Select the Insert Merge Field option from the dropdown menu to insert merge fields.

4. Select where you want the conditional text to be placed.

5. Press Alt + F9 so you can see the field codes

6. To apply conditional formatting, Go to Mailings > Rules > If…Then…Else and a pop-up box will open

If..then..else.. option

7. In the Field name dropdown select the desired field from the data source (MS Excel File) you want to use for conditional text

if...then...else... popup

8. In the Comparison box, choose a method for comparing the data value.

9. In the Compare to box, type in the comparison value

10. In the Insert this text box, enter the content that appears in the document when the comparison criteria is met.

11. In the Otherwise insert this text box, type in the words that would be included in the document when the comparison criteria is not met

12. Select OK.

13. If you want to apply conditional formatting manually, you need to use Ctrl+F9 to add the curly braces and the field codes.

Note: Don’t use spaces in your field names.

Formatting the Conditional Text in Word Mail Merge

When you perform a merge mail in Microsoft Word, the formatting of an MS Excel data file is lost. You must edit the field code if you want to change the color of the conditional text. For example, if you want to change the color of “Truetext” to blue, modify the field code as follows:

{ IF { MERGEFIELD Industry } = “Recruiting” “hope the recruiting business is going well and you’re placing lots of candidates!” “hope things are going well for you.”}

Nesting Conditional Statements / Multiple If- Else Conditions in Word Mail Merge

If you want to use multiple IF statements, simply add more IF functions in the field code, as shown below:

{ IF Condition1 “Truetext” { IF Condition2 “Truetext” “Falsetext” }}

{ IF { MERGEFIELD Industry } = “Recruiting” “hope the recruiting business is going well and you’re placing lots of candidates!” { IF { MERGEFIELD Industry } = “Sales” hope your sales are high and you’re closing deals left and right! “hope things are going well for you.”}}

Problems with Conditional Formatting in Word Mail Merge

  1. If you have more than one condition or wish to perform more complex mail merge personalization, the procedure gets considerably more difficult.
  2. You can not simply type the curly braces {}; MS Word must add these. You can only create a blank field by pressing Ctrl+F9. If you type the curly braces manually, the conditional formatting won’t work.
  3. The text you use for your TrueText or FalseText should not include any special characters, such as slashes (/), Inverted Commas, Quotation Marks, brackets ([]), or braces ({). This is because MS Word will not output them during the mail merge. 
  4. If any of the “IF” fields are blank during mail merge, MS word won’t be able to suppress them. As a result, you will see additional blank lines or inconsistent output in your mail merge letters. To eliminate them, you need to add a “b” after the merge field.
  5. If you have any hyperlinks in the conditional text, those will not be outputted by the simple If…Then…Else… rule.

Conditional Text Automation with GMass and Gmail

GMass has created a simple solution to send personalized mail merges using Gmail that eliminates the typical conditional formatting and other mail merge issues associated with MS Word. With GMass, you can use If/Then and other statements in your Subject and Message to hyper-personalize content based on any criteria you have associated with each email address. Read our full guide on conditional content for personalized emails.

Conditional mail merge in Gmass

Along with this, you can also:

Personalize links and URLs for each recipient, including anchor links without link breakage that can otherwise occur in the Compose window.

Personalize attachments by sending individual images, invoices, or documents to each recipient in a mass email.

Personalize images for each recipient to include a different team logo, pet breed, or astrological sign, etc.

Personalize large blocks of text according to the needs of each recipient, such as a different promotional offer for different levels of customers, or for customers in different zip codes.

Send your campaign to a personalized CC or BCC address for each recipient to keep the associated salesperson or distributor in the loop according to their respective territories or accounts.

Personalize the To header of each individual email so that your contact’s First and Last name appear as part of the To line instead of just their email address.

For our full set of personalization documentation see the personalization category page on this blog.

We’ve tried to make GMass as simple to use as possible. It is simple to double-check your personalization before sending your email to all of your recipients. You may use the Send Test button with the Create Drafts option to see instantly what personalization to everyone on your list will look like. Simply select the “Send Test” option and check your Gmail DRAFTS folder. When you’re ready to send your campaign with the red GMass button, don’t forget to switch the Action back to “Send email.”

Conclusion

The Microsoft Word mail merge tool is powerful, but it has certain limits. For example, it isn’t well-equipped to handle complex mail merges or conditional content, resulting in errors and formatting issues that are difficult to troubleshoot. You can use GMass to create hyper-personalized bulk email campaigns using Gmail. With in-depth analytics and automation, you’ll have all you need to easily send, manage, and follow up on your emails. Why not download the GMass Chrome extension today and try it yourself?

See why 99% of users say they’ve had their best deliverability ever with GMass

Email marketing, cold email, and mail merge all in one tool — that works inside Gmail

TRY GMASS FOR FREE

Download Chrome extension — 30 second intall!
No credit card required

Love what you’re reading? Get the latest email strategy and tips & stay in touch.

Word IF Then Else Rule (Mail Merge) Insert Fields

Sep 03, 2015 in Mail Merge

Previously in the article Word IF Then Else Rule (Mail Merge) I’ve explained how you can use the If Then Rule in Mail Merge. In that article the If Then Else Field would insert a text string based on the result of the comparison.

In this article I will explain how you can insert Field Values rather than Text Strings using the If Then Else Rule.


Example:

Assume you are sending letters to 100 recipients. In the Recipient List created for the recipients, there is an Age Field. What we want to do, is to compare the Age Field with the value 18.

  • If the recipients is older than 18 years, then we want the Age to be displayed
  • But if the recipient is younger than 18 years, we want the Text String “Under 18′ to display.

This will be the letter sent out to a 25 year old:

25 Year old Letter

and this will be a letter sent out to a 14 year old:
Under 18 Letter


Step 1:

Follow the same steps explained in the article Word IF Then Else Rule (Mail Merge).


Step 2:

After completing step 1, press Alt+F9. This is what you will see:
AltF9

The top part is the Greeting Line Field (which is irrelevant to our discussion):
Greeting Line Field
Under that line you will see this:
IF Then Else
This is the If Then Else Field:

{ IF { MERGEFIELD Age } > 18 "Over 18" "Under 18" }


The If Then Else Field:

As you can see the If Then Else Field has 3 parts:

If Statement:

This part compares the Age Field with the value 18:

IF { MERGEFIELD Age } > 18 

Result If True:

This is what will be displayed if the If Statement returns True:

"Over 18"

Result If False:

This is what will be displayed if the If Statement returns False:

"Under 18"

What we need to do is to change the Result If True value to { MERGEFIELD Age }:

{ IF { MERGEFIELD Age } > 18 { MERGEFIELD Age } "Under 18" }

By doing this, when the result of the If Statement is true, the Age of the recipient will be displayed.


Step 3:

As explained in the previous section we need to replace the text "Over 18" with the Age Field. In order to do this select and delete the text "Over 18":
Select
Deleete
While the cursor is still in that location insert the Age Field:
Insert Age Field
Insert Age Field 2
Press Alt+F9 to return the normal view:
Result
Result 2
You can download the sample file used in this article from the link below:

  • Insert Field.Zip

See also:

  • Word, Mail Merge
  • Word IF Then Else Rule (Mail Merge)
  • Word Insert Merge Field (Mail Merge)

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website  www.software-solutions-online.com

Понравилась статья? Поделить с друзьями:
  • Word idiom in a sentence
  • Word in dialog based
  • Word icons not displaying
  • Word in context pdf
  • Word in chinese and english