I am trying to work out a macro that replaces the letter O with zero ('0') in any position within a digit string. I cannot go any further into the tentative code here below. Thanks!
Code:
Sub LetterToZero()
'Replace with zero any digit string of any length containing the letter O
'Test sequence: This sequence 145O or this 4O56 or this O4578
Set aRng = ActiveDocument.StoryRanges(wdMainTextStory)
With aRng.Find
.ClearFormatting
.Text = "O[0-9]"
' .Text = "[0-9]O"
' find letter O inside digit string
' .Replacement.Text = "0" 'Replace only the letter O
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWildcards = True
.Execute
'If .Found = True Then MsgBox "Found " & aRng.Text
End With
End Sub