How to find & replace text in tables only in word 2003?

Copper Contributor

Hello,
I want to find and replace text in tables only, without affecting the rest of the text.
I tried various solutions found on the internet, but they don't work in my case.

[I've solved this problem using the well known solution: adding a special symbol at the end of each table cell by replacing formatted  text in tables with ^&§§§, etc. but it's not efficient enough, I'm looking for something better.]
Thank you for your suggestions.

 

4 Replies

@Funfunfan Use a macro containing the following code

 

Dim strReplace As String
Dim strFind As String
strFind = InputBox("Insert the text to be replaced")
strReplace = InputBox("Insert the replacement text")
Selection.HomeKey wdStory
With Selection.Find
    Do While .Execute(FindText:=strFind, Forward:=True, _
    MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=True) = True
        If Selection.Information(wdWithInTable) = True Then
            Selection.Text = strReplace
        Else
            Selection.Collapse wdCollapseEnd
        End If
    Loop
End With
Thank you. It only replaces one instance. I need the Replace All function working in tables only.
Replace
Wrap:=wdFindStop
with
Wrap:=wdFindContinue

Avoid making a replacement such as Testing for Test
Thanks. It worked, but for some reason each time I apply this, the same portion of the text that is not in table starts flashing, and after 5 or 10 seconds word goes into Not responding mode and brings out the Close program dialog.