View Single Post
 
Old 10-31-2023, 06:52 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi! Greg's macro is very interesting (as usual). As a variant, you can try this simple but swift code:
Code:
Sub O_To_Zero()
''Replace letters "O" followed and/or preceded by a digit
'with zeros.

    Set aRng = ActiveDocument.StoryRanges(wdMainTextStory)
    With aRng.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .text = "O([0-9])"
      .Replacement.text = "0\1"
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
      .text = "([0-9])O"
      .Replacement.text = "\10"
      .Execute Replace:=wdReplaceAll
    End With
End Sub
Reply With Quote