Microsoft로 로그인
로그인하거나 계정을 만듭니다.
안녕하세요.
다른 계정을 선택합니다.
계정이 여러 개 있음
로그인할 계정을 선택합니다.
영어
죄송합니다. 이 문서는 귀하의 언어로 사용할 수 없습니다.

For a Microsoft Word 98 Macintosh Edition version of this article, see
189026.

For a Microsoft Word 97 version of this article, see
177287.

In a mail merge main document, you can use an IF (IF...THEN...ELSE) conditional statement to check whether one condition or multiple conditions are met.

This article provides a method of nesting COMPARE statements in an IF field to test whether the conditions you want are met.

For additional information about evaluating MERGEFIELDS without using the COMPARE field, click the article numbers below to view the articles in the Microsoft Knowledge Base:

214827 WD2000: How to Use Nested IF Fields in a Mail Merge Document

212028 WD2000: How to Use Conditional Field to Specify Number of Digits

212178 WD2000: Cannot Merge a Barcode Field Based on a Condition

220250 WD2000: Err Msg: "Fields Are Nested Too Deeply" in Mail Merge

Summary

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

NOTE: To type field braces ( { } ) in a Word document, press CTRL+F9. To turn field codes on or off, press ALT+F9.

To Test Whether Multiple Conditions Are Met

To test whether multiple fields meet certain conditions, you can use an AND conditional statement in your mail merge main document similar to the following:

{ IF { = AND ( { COMPARE { MERGEFIELD Field_1 } = "Value"}, { COMPARE { MERGEFIELD Field_2 } = "Value" } ) } = 1 "True Instructions" "False Instructions" } The result of these nested COMPARE statements is the "True Instructions" when both Field_1 and Field_2 are equal to "Value"; otherwise, the "False Instructions" is given as the result.

NOTES:

  • When all of the conditions of the AND statement are met, the value returned by the statement is equal to 1 (this results in the True Instructions being returned).

  • When all of the conditions of the AND statement are not met, the value returned by the statement is equal to 0 (this results in the False Instructions being returned).

To Test Whether One Condition Is Met

To test whether one of the fields meets a particular condition, you can use an OR conditional statement in your mail merge main document similar to the following:

{ IF { = OR ( { COMPARE { MERGEFIELD Field_1 } <= "Value" }, { COMPARE { MERGEFIELD Field_2 } >= "Value" } ) } = 1 "True Instructions" "False Instructions" } The result of these nested COMPARE statements is the "True Instructions" when either Field_1 or Field_2 is equal to "Value"; otherwise, the "False Instructions" is given as the result.

NOTES:

  • When any of the conditions of the OR statement is met, the value returned by the statement is equal to 1 (this results in the True Instructions being returned).

  • When all of the conditions of the OR statement are not met, the value returned by the statement is equal to 0 (this results in the False Instructions being returned).

More Information

도움이 더 필요하세요?

더 많은 옵션을 원하세요?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

이 정보가 유용한가요?

사용 경험에 어떠한 영향을 주었나요?
제출을 누르면 피드백이 Microsoft 제품과 서비스를 개선하는 데 사용됩니다. IT 관리자는 이 데이터를 수집할 수 있습니다. 개인정보처리방침

의견 주셔서 감사합니다!

×