Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Understanding the COMPARE Field.

Understanding the COMPARE Field

Written by Allen Wyatt (last updated August 15, 2020)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


One of the fields that Word makes available for automating your documents is the COMPARE field. Most people don't use this field that much because it can be confusing to do so. The entire purpose of the COMPARE field is to do exactly what it says—compare values. All you need to do is provide the two values (along with the comparison operator), and COMPARE will return either a 1 if the comparison is true or a 0 if it is false.

For example, let's say you wanted to compare the contents of a bookmark to see if it was equal to a specific value. If your bookmark name is MyBook, the following COMPARE field will do the trick:

{ COMPARE { MyBook } = "TestText" )

If the bookmark (MyBook) is equal to TestText, then the COMPARE field returns a value of 1 (True). If it is not, then COMPARE returns a value of 0 (False).

As you might imagine, returning a zero or a one, by itself, may not be that valuable of a feature. Where COMPARE comes in handiest is when you use it as an argument for one of the other comparison fields. For instance, you might use COMPARE in conjunction with the IF field to specify conditional text for your document. When used in this way, the value of COMPARE is limited only by your imagination.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13180) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Understanding the COMPARE Field.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Controlling Display of the Status Bar

The status bar is used to display all sorts of information about the document on which you are working. Depending on your ...

Discover More

Limits on Path Length in Word

When you organize your hard drive, it is easy to go hog-wild with folders and subfolders. You need to know that how you ...

Discover More

Signs Your Computer has a Virus

Think your system might be infected with a virus? How would you know if it was? Here are some quick indicators that your ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Printing Index Field Codes

Word allows you to configure what you see so that field codes are visible instead of the results of those field codes. ...

Discover More

Word Count for a Portion of a Document

Word doesn't provide a field that allows you to return a word count for a portion of your document, but you can create ...

Discover More

Inserting the Document Revision Number

Need to know how many times your document has been saved? Word keeps track of this information, and makes it easily ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.