Forum Discussion
Funfunfan
Apr 30, 2022Copper Contributor
How to find & replace text in tables only in word 2003?
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.
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
- FunfunfanCopper ContributorThank 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