DEV Community

Oscar Sun(孫守真字任真)
Oscar Sun(孫守真字任真)

Posted on

Answer: MSword - How to use find and replace to conduct advanced replacing

Is this is what you want?

Sub ReplaceText_MSword__How_to_use_find_and_replace_to_conduct_advanced_replacing()
    With ActiveDocument.Content.Find
        .ClearFormatting
        .Text = "p = 0.([0-9]{3})"
        .Replacement.ClearFormatting
        .Replacement.Text = "(0.\1)"
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
    End With
End Sub

Top comments (0)