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

%3CLINGO-SUB%20id%3D%22lingo-sub-3299552%22%20slang%3D%22en-US%22%3EHow%20to%20find%20%26amp%3B%20replace%20text%20in%20tables%20only%20in%20word%202003%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3299552%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3CBR%20%2F%3EI%20want%20to%20find%20and%20replace%20text%20in%20tables%20only%2C%20without%20affecting%20the%20rest%20of%20the%20text.%3CBR%20%2F%3EI%20tried%20various%20solutions%20found%20on%20the%20internet%2C%20but%20they%20don't%20work%20in%20my%20case.%3C%2FP%3E%3CP%3E%5BI've%20solved%20this%20problem%20using%20the%20well%20known%20solution%3A%20adding%20a%20special%20symbol%20at%20the%20end%20of%20each%20table%20cell%20by%20replacing%20formatted%26nbsp%3B%20text%20in%20tables%20with%26nbsp%3B%3CSPAN%3E%5E%26amp%3B%C2%A7%C2%A7%C2%A7%2C%20etc.%20but%20it's%20not%20efficient%20enough%2C%20I'm%20looking%20for%20something%20better.%3C%2FSPAN%3E%5D%3CBR%20%2F%3EThank%20you%20for%20your%20suggestions.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3300194%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20%26amp%3B%20replace%20text%20in%20tables%20only%20in%20word%202003%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3300194%22%20slang%3D%22en-US%22%3EThanks.%20It%20worked%2C%20but%20for%20some%20reason%20each%20time%20I%20apply%20this%2C%20the%20same%20portion%20of%20the%20text%20that%20is%20not%20in%20table%20starts%20flashing%2C%20and%20after%205%20or%2010%20seconds%20word%20goes%20into%20Not%20responding%20mode%20and%20brings%20out%20the%20Close%20program%20dialog.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3300174%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20%26amp%3B%20replace%20text%20in%20tables%20only%20in%20word%202003%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3300174%22%20slang%3D%22en-US%22%3EReplace%20%3CBR%20%2F%3EWrap%3A%3DwdFindStop%3CBR%20%2F%3Ewith%3CBR%20%2F%3EWrap%3A%3DwdFindContinue%3CBR%20%2F%3E%3CBR%20%2F%3EAvoid%20making%20a%20replacement%20such%20as%20Testing%20for%20Test%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3300050%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20%26amp%3B%20replace%20text%20in%20tables%20only%20in%20word%202003%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3300050%22%20slang%3D%22en-US%22%3EThank%20you.%20It%20only%20replaces%20one%20instance.%20I%20need%20the%20Replace%20All%20function%20working%20in%20tables%20only.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3299944%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20find%20%26amp%3B%20replace%20text%20in%20tables%20only%20in%20word%202003%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3299944%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1331216%22%20target%3D%22_blank%22%3E%40Funfunfan%3C%2FA%3E%26nbsp%3BUse%20a%20macro%20containing%20the%20following%20code%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3EDim%20strReplace%20As%20String%0ADim%20strFind%20As%20String%0AstrFind%20%3D%20InputBox(%22Insert%20the%20text%20to%20be%20replaced%22)%0AstrReplace%20%3D%20InputBox(%22Insert%20the%20replacement%20text%22)%0ASelection.HomeKey%20wdStory%0AWith%20Selection.Find%0A%20%20%20%20Do%20While%20.Execute(FindText%3A%3DstrFind%2C%20Forward%3A%3DTrue%2C%20_%0A%20%20%20%20MatchWildcards%3A%3DFalse%2C%20Wrap%3A%3DwdFindStop%2C%20MatchCase%3A%3DTrue)%20%3D%20True%0A%20%20%20%20%20%20%20%20If%20Selection.Information(wdWithInTable)%20%3D%20True%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20Selection.Text%20%3D%20strReplace%0A%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20Selection.Collapse%20wdCollapseEnd%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Loop%0AEnd%20With%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Occasional 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.