How to find and replace programmatically in an ENTIRE Word document

I have a Word document with text in tables and texts outside of tables. I want to find and replace all text, not just text outside of tables. The document content property is just the "main story", not tables. I don't want to iterate over all the table objects. I just want to find and replace all over the text, just like when I do it manually using the Word gui.

Please save me from the mental hell I'm burning in.

[The stench of burning flesh begins to bother me. Almost as much as the excruciating pain in my limbs.]

[My legs and arms were consumed by the flames. I write this with my nose, which is sticky with the molten plastic from the keys.]

+2


source to share


1 answer


Use the Find property, this is the same as the user interface. Find the help topic for "Find Property" to get started.



With ActiveDocument.Range.Find
    .Text = "hi"
    .Replacement.Text = "hello"
    .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With

      

+2


source







All Articles