View Single Post
 
Old 10-21-2023, 07:23 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Default

Sorry, but I'm here again. The code variant here below changes '95 to '9. Why? Thanks!
Code:
Sub SingleBeforeDigit()
  'Replace Chr(145) with Chr(146) before a digit (as in ’95)
  Dim oRng As Range
  Set oRng = ActiveDocument.Range
  Options.AutoFormatAsYouTypeReplaceQuotes = False
With oRng.Find
    .ClearFormatting
    .Text = Chr(145) & "([0-9])" & "[!^02]" 'to avoid footnote ref. marks
    .Replacement.Text = Chr(146) & "\1"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
End With
  Options.AutoFormatAsYouTypeReplaceQuotes = True
End Sub
Reply With Quote