Thread: [Solved] find and replace with format
View Single Post
 
Old 08-02-2022, 03:04 PM
macropod's Avatar
macropod macropod is online now Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,387
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub etalnew()
Application.ScreenUpdating = False
Options.DefaultHighlightColorIndex = wdDarkYellow
Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges   
  With rngStory.Find
    .Text = "<et al>"
    .Replacement.Text = "et^sal"
    .Replacement.Highlight = True
    .Replacement.Font.Italic = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
Next rngStory
Application.ScreenUpdating = True
End Sub
Do note that textboxes, for example, won't be processed by such code and that Find/Replace is a bit flakey with page headers & footers. If you have 'et al' in any of those, you might need different code. See: Using a Macro to Replace Text Wherever It Appears in a Document
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote