Finding and Replacing Text Boxes

Written by Allen Wyatt (last updated April 13, 2024)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


Tim wonders if Find and Replace can be used to search for and locate text boxes. He would like to search for text boxes and replace each of them with a graphic, as he finds this almost impossible to do manually when some text boxes are essentially invisible in his document.

If your text boxes are inline with your text, then you can use Find and Replace to locate and replace them. All you need to do is to display the Replace tab of the Find and Replace dialog box and, in the Find What box, enter ^g. This is the code for find graphics, but Word treats text boxes as if they are graphics when they are inline.

The problem is, of course, that most text boxes are not inline—text wraps around them and they reside on their own layer. For these types of text boxes you must use a macro to do the searching and replacing. The following is an example of one you could use:

Sub ReplaceTextBox()
    Dim shp As Shape

    For Each shp In ActiveDocument.Shapes
        If shp.Type = msoTextBox Then
            shp.Select
            shp.Delete
            Selection.PasteAndFormat (wdPasteDefault)
        End If
    Next
End Sub

To use the macro, select the graphic you want to use in your replacement and then press Ctrl+C. This places the graphic in the Clipboard. When you run the macro, it is this graphic—the one in the Clipboard—that is pasted into the document in place of each text box.

You should be aware that the macro replaces all of the text boxes in a document with the graphics. If you wanted to selectively replace text boxes, the coding would be a good deal more complex.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (2894) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

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

Setting Print Titles

Excel allows you to specify certain rows or columns that will be repeated on the pages of a printout. Here's how to set ...

Discover More

Controlling the Printing of Highlighting

Using Word's built-in highlighter tool can be a great way to add markup to a document and attract a reader's eyes to ...

Discover More

Determining if Overtype Mode is Active

Your macro may need to determine if the user has overtype mode turned on. You can find out the overtype status easily by ...

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)

Making Ctrl+F Work Traditionally

One change introduced in Word 2010 was the new navigation pane that is used for simple searching of information. This ...

Discover More

Searching for Items in an Automatically Numbered List

The Find and Replace capabilities of Word can be very powerful, but there are some things you cannot search for. One such ...

Discover More

Changing Decimal Commas to Decimal Points

If you have a document that was produced in a country where decimal commas are used instead of decimal points, you may be ...

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 four less than 7?

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.