View Single Post
 
Old 01-10-2024, 05:04 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

The Execute ReplaceAll command doesn't track the formatting change so you need to loop that step.
Code:
Sub Macro1()
  Dim aRng As Range, aRng2 As Range
  ActiveDocument.TrackRevisions = True
  ActiveDocument.TrackFormatting = True
  
  Set aRng = Selection.Range
  Set aRng2 = aRng.Duplicate
  With aRng.Find
    .ClearFormatting
    .Font.Color = wdColorRed
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchByte = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    Do While .Execute = True
      aRng.Font.ColorIndex = wdBlack
      aRng.End = aRng2.End
    Loop
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote