Thread: [Solved] find and replace with format
View Single Post
 
Old 08-02-2022, 10:30 AM
karkey karkey is offline Windows 10 Office 2013
Novice
 
Join Date: Jan 2021
Posts: 19
karkey is on a distinguished road
Default find and replace with format

While replace I need to italic and highlight the word (et^sal).

Code:
Sub etalnew()
  Dim rngStory As Range
  For Each rngStory In ActiveDocument.StoryRanges
    
    Options.DefaultHighlightColorIndex = wdDarkYellow
    Selection.Find.Replacement.Highlight = True
    
    With rngStory.Find
      .Text = "<et al>"
      .Replacement.Text = "et^sal"
      .Replacement.Highlight = True
      .Wrap = wdFindContinue
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
  Next rngStory
End Sub

Last edited by macropod; 08-02-2022 at 02:54 PM. Reason: Added code tags to restore formatting
Reply With Quote