Find and Replace in Text Boxes

by Allen Wyatt
(last updated January 27, 2017)

6

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

Displaying a Hidden First Row

If you hide the first rows of a worksheet, you may have a hard time getting those rows visible again. Here's a simple way to ...

Discover More

Inserting a Sound File in Your Worksheet

Some worksheets are better understood through the spoken word or with musical accompaniment. Sound files can be easily ...

Discover More

Endnotes by Chapter

Word allows you to easily add endnotes to your document. It even allows you to specify where those endnotes should appear in ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (menu)

Selective Formatting in Replacements

Do you need to replace text with a term or phrase that uses multiple formats? You can perform this seemingly complex task ...

Discover More

Replacing Text with a Graphic

The Find and Replace feature in Word provides you with some powerful tools you can use to process a document. One such tool ...

Discover More

Replacing Some Smart Quotes

Smart quotes look great in a document, but may not be right for all instances of quote marks or apostrophes. If you need to ...

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}] 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 7 - 0?

2017-06-01 20:06:46

David DeGroot

Or also, if the cursor is in the textbox when she does the Find and Replace, it will only search inside the one textbox. If the cursor is located in a body paragraph, then Find and Replace searches all textboxes.


2016-01-27 11:48:27

Sandor VASONY

I would appreciate your help in the following problem concerning "Find and Replace" feature in Word 2013.

I have got about 300 frames in a Word 2013 document, exactly with the same positioning and frame datas.

I spent hours to try to find those frames, I specified all the possible datas of the frames what to find, but there is no success.

Could anyone send advices how to do this job, and what is the real cause of the situation?

Thank you, regards

Sandor


2015-09-04 07:07:39

Ken Endacott

Find and replace has many peculiarities. If you start with the cursor in the document body, it will search the document body as well as headers and footers and also all textboxes in the document body but not textboxes in headers and footers.

If the cursor is in a header (or footer) it will search just the text in that header (or footer) but not in any textboxes in that header (or footer).

If the cursor is inside a textbox then it will search only the text in that textbox.

Find & Replace run from a macro acts differently. If the cursor is in the document body then only the document body text is searched. This applies even if the macro has been recorded from a manual Find & Replace.

If you want to search every part of a document then a macro is needed to search the text in every StoryRange. Examples are given by Doug Robbins but Doug's macros only search textboxes in the main body not textboxes in headers, footers or other StoryRanges. Additional coding is needed to make sure that evert textbox is searched.


2015-09-03 11:14:38

Bill

I had the same problem as Ralph, it does not search text boxes and selecting all (Ctrl+A) does not help.


2015-06-26 05:53:01

Mihkel Kohava

FIX:
Select all (Ctrl+A) and then use Find and Replace


2015-06-23 12:33:32

Ralph

I had the same problem in Word 2013; searching for instances of a word that was located in text boxes throughout an unmerged document. (I only mention that it was unmerged because in your example the document was merged)

I had inserted text boxes in numerous locations in the document to help clarify the surrounding text. I just wanted to change the word "Project" wherever it occurred in the document with the word "Order".

Word 2013 found some instances of the word "Project" then reported that there were no more occurrences. It had missed more than half of them. I re-started the search from the beginning of the document several times, but to no avail.

I did discover that it would find them if I searched from within each text box, but of course, there were many text boxes, so that defeated the purpose of the search. Eventually, I replaced all the remaining occurrences manually.


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.

Newest Tips
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.