View Single Post
 
Old 06-11-2022, 07:19 PM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,175
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Here is one that handles more including multi-word AC entries. It is slow but may be worth using.
Code:
  Sub AutoCorrectBruteReplace2()
      ' https://answers.microsoft.com/en-us/msoffice/forum/all/macro-for-autocorrect/91f9bdb1-47ac-4cec-9842-5f1ee38bd7cf?page=1
      ' rianvillareal 2022-06-11 modified by Charles Kenyon with help by Hans Vogelar to use range and work with selected text
      ' It is slow. Handles multi-word entries. Does not handle fractions
      ' If text is selected, it operates only on selected text
      '       If nothing selected, it operates on entire document
      '
      Dim oEntry As Word.AutoCorrectEntry
      Dim oRng   As range
      Set oRng = Selection.range
      For Each oEntry In AutoCorrect.Entries
          With oRng.Find
              .ClearFormatting
              .Replacement.ClearFormatting
              .Text = oEntry.Name
              .Replacement.Text = oEntry.Value
              .Forward = True
              .Wrap = wdFindStop
              .Format = False
              .MatchCase = False
              .MatchWholeWord = True
              .MatchWildcards = False
              .MatchSoundsLike = False
              .MatchAllWordForms = False
              .Execute Replace:=wdReplaceAll
          End With
      Next
  End Sub
Reply With Quote