View Single Post
 
Old 10-20-2023, 06:42 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Question Replace apostrophe mark before a digit

The following macro does its job, but I'm not satisfied with it. Is there a better way to obtain the same result? Thanks!


Code:
Sub SingleBeforeDigit()
'Replace Chr(145) with Chr(146) before a digit (as in ’95)
  Dim oRng As Range, iType As Integer
  For iType = 1 To 2
Set oRng = ActiveDocument.StoryRanges(iType)
With oRng.Find
    .ClearFormatting
    .Text = Chr(145) & "([0-9])"
    .Font.Superscript = False 'to avoid footnote reference marks
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
While .Execute
oRng.Characters.First = Chr(146)
Wend
End With
   Next iType
End Sub
Reply With Quote