View Single Post
 
Old 10-20-2023, 05:49 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You can just use ReplaceAll. Also the direction doesn't matter when you are working on the whole range and wrapping.
Code:
Sub SingleBeforeDigit()
  'Replace Chr(145) with Chr(146) before a digit (as in ’95)
  Dim oRng As Range
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .ClearFormatting
    .Text = Chr(145) & "([0-9])"
    .Replacement.Text = Chr(146) & "\1"
    .Font.Superscript = False       'to avoid footnote reference marks
    .Replacement.Highlight = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote