Skip to content

How to Find and Replace in Word Text Boxes

Find and replace inside Microsoft Word Text Boxes is something that Word can’t do directly but is possible in two different ways.

As we’ve already explained, Word can only find text inside Text Boxes as either part of a search of the entire document or just the content of Text Boxes.

The trouble comes if you want to Find and Replace inside a Text Box.  Even in ‘Advanced Find’ there’s no option to limit the scope to Text Boxes only, like there is in the Find dialog box.

At first look, it seems like there’s no way to do a Replace inside Word Text Boxes. But with a little Word trickery, it is possible in two different ways,

Find then manually Replace, leaving the Find dialog open

OR

VBA macro. 

Find then manually replace

For small jobs, the easiest workaround is to use the Find dialogs ability to stay open while you edit the document. Then jump to the next search result.

This trick is great when you need to find things in a document then make changes that can be done with an automatic Replace.  In this case we’ll use it to just find text in Text Boxes then make each change.

  1. Open Advanced Find and setup a Find for the word/phrase.
    1. Ensure that Find in … is set to ‘Text Boxes in Main Document’.
  • Click on Find Next to jump to the first result.
  • Click in the document and make any changes you want. 
    • Leave the Find and Replace box open. If necessary, drag it away from the document so you can see what you’re doing.
    • OPTIONAL: copy text you’re using to replace into the clipboard. That makes it faster to replace each time with a simple paste.
  • Choose Find Next to move to the next Find result then make the changes.
    • Paste in text from clipboard, if available.
    • Repeat Step 3 as necessary.
  • When you’re finished, choose Close on the Find and Replace dialog.

VBA to Replace in Text Boxes

While Word’s in-built Replace can’t work in Text Boxes, the ability is there in VBA.

Each Text Box is handled as a Shape object and it’s possible to replace text inside a Shape.

The basic code looks like this:

Sub ReplaceinTextBoxes(FindText, ReplaceText)
    Dim Shp As Shape
    For Each Shp In ActiveDocument.Shapes
      If Shp.Type = msoTextBox Then
        With Shp.TextFrame.TextRange.Find
          .ClearFormatting
          .Replacement.ClearFormatting
          .Execute FindText:=FindText, _
                   ReplaceWith:=ReplaceText, _
                   Replace:=wdReplaceAll
        End With
      End If
    Next Shp
End Sub

Explaining the VBA

  1. Looks for each Shape in the current document
  2. Checks if the Shape is a Text Box and, if it is
    1. Sets up a Find command which
      1. Clears all formatting text for both Find and Replace
      1. Executes a Replace for each instance of the FindText with the ReplaceText.
  3. Repeats Step 2 for each Text Box in the document

Call that sub-routine from another sub like this.

Sub TextBoxReplace()

Dim FindText As String

Dim ReplaceText As String

FindText = "Berlin"

ReplaceText = "Currywurst"

‘ OR add a UserForm to get the Find and Replace Text.

Call ReplaceinTextBoxes(FindText, ReplaceText)

End Sub

How to Find inside Text Boxes for Microsoft Word

About this author

Office-Watch.com

Office Watch is the independent source of Microsoft Office news, tips and help since 1996. Don't miss our famous free newsletter.