searching for words in text boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is there no way to search just text boxes for a particular word?

when i do a "find" on a specific word, it finds all locations of that word as long as it's not in a text box. i tried selecting multiple text boxes (as it says to do for a word count) and searching that way. i selected two text boxes and did a search on "the" to test this; "the" appears at least once in both text boxes. i get a prompt saying "word has finished searching the selection. the search item was not found".
 
You could use the following macro:

Sub SearchTextBoxes()
Dim sh As Shape
Dim myFindWord, myReplaceWord As String
Message1 = "Type the word you want to find."
Title1 = "Text Box Word Finder"
Message2 = "Type the replacement word."
Title2 = "Text Box Word Replacement"
myFindWord = InputBox(Message1, Title1)
myReplaceWord = InputBox(Message2, Title2)
For Each sh In ActiveDocument.Shapes
If sh.TextFrame.HasText Then
sh.TextFrame.TextRange.Find.ClearFormatting

sh.TextFrame.TextRange.Find.Replacement.ClearFormatting
With sh.TextFrame.TextRange.Find
.Text = myFindWord
.Replacement.Text = myReplaceWord
.Wrap = wdFindContinue
.Forward = True
.Format = False
.MatchCase = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End If
Next sh

End Sub
-----Original Message-----
is there no way to search just text boxes for a particular word?

when i do a "find" on a specific word, it finds all
locations of that word as long as it's not in a text box.
i tried selecting multiple text boxes (as it says to do
for a word count) and searching that way. i selected two
text boxes and did a search on "the" to test this; "the"
appears at least once in both text boxes. i get a prompt
saying "word has finished searching the selection. the
search item was not found".
 
Back
Top