Find and Replace in Text Boxes

by Allen Wyatt
(last updated January 27, 2017)

Margaret wrote about a problem she was having performing a find and replace for something in a text box. It seems that Margaret created a merged document, and then noticed that a reference number in a text box was incorrect. She tried to do a search and replace to change all instances of the reference number, but Word would not find and replace it.

In doing some testing, it appears that Word will find information in a text box and replace it just fine, provided that the text box is visible when you actual do the find and replace operation. For instance, if you place some text in a text box, and the same text in the main portion of the document, and then do a find and replace operation for a piece of text that is common to both the document and the text box, then Word will successfully replace all the instances—even those in the text box.

Why wouldn't Word find and replace the reference number in Margaret's situation? There are only a few possibilities. First, the reference number may not really be text. If the reference number was made with an embedded field, then the find and replace will not be reliable. For instance, if the reference number is created with the SEQ field, you can find what is displayed by the field, and you can replace it, but if the fields are updated (which happens when you print), then the "replaced" number reverts back to what the underlying field code tells it to be.

Second, if the reference number is linked in some way to another document (again, using a field), then Word cannot correctly replace the information. This is because the reference number is not in the current document, but in another document linked to the current document. To make the change, you would need to change the source document.

Finally, it could be that the reference number, if it was merged from another data source, contains some non-printable characters that make finding it impossible. For instance, let's say that the reference number you want to find is QR378, but that the text in the merge source includes a non-printing character of some sort between the "R" and the "3". If this is the case, then Word won't find the reference number when you search for QR378. The only way to correct this situation is to clean up the original data source and then run the merge again.

It should be noted that the discussion so far reflects the behavior of Word if you are replacing text using the Find and Replace dialog box. If you are actually doing the searching and replacing in a macro, it is interesting that Word won't find appropriate text matches in text boxes. You can, in fact, use the macro recorder to record a perfectly good Find and Replace operation—that does find and replace text in a text box—and when you later replay the macro, it won't find the information in the text box.

If you are doing searching and replacing in a macro, the following article by Doug Robbins on the Word MVP site explains what is going on:

http://wordmvp.com/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1331) applies to Microsoft Word 97, 2000, 2002, and 2003.

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

Creating an Index Entry for a Range of Pages

Putting together an index for your documents can be challenging, but Word provides some great tools to make the task easier. ...

Discover More

Inserting the Document Creation Date

One of the pieces of information tracked by Word is when a document was first created. Here's how you can access that date ...

Discover More

Clearing Everything Except Formulas

Need to get rid of everything in a worksheet except for your formulas? You can do it rather easily by applying the ideas in ...

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 (MENU)

Removing HTTP from URLs

Having problems when it comes to replacing information in URLs? You're not the only one; it can be confusing making mass ...

Discover More

Searching for Adjectives and Adverbs

Searching for different types of words in your documents is a nice thing to contemplate, but it is much harder to do in ...

Discover More

Finding the Previous Occurrence

Using Word's Object Browser, it is very easy to move among different instances of what you want to search in your document. ...

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 for this tip:

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 menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

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.

Links and Sharing
Share