![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
Your code work just fine. There is only this line missing :
Code:
Selection.Find.Replacement.Font.Italic = True Code:
Selection.Find.Replacement.Highlight = True |
#3
|
||||
|
||||
![]()
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LQuinn | Word VBA | 2 | 05-14-2021 11:15 PM |
Find/Replace using format of cell | catflap | Excel | 1 | 09-11-2017 07:28 AM |
![]() |
winningson | Word | 3 | 01-19-2013 05:38 AM |
![]() |
Jack | Word VBA | 2 | 12-12-2012 09:24 PM |
![]() |
paulkaye | Word | 4 | 12-06-2011 11:05 PM |