View Single Post
 
Old 10-12-2023, 07:20 AM
syl3786 syl3786 is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Question Simple issue: formatting mroe than one text just using one module

Hi all,



I want to use just one module to format more than one text. How to do that?


For instance, I want to italicise the text "et al" and "apple". But i am stupid to use two modules to italicise them separately.



Below please find the code:


Code:
Sub formatting()


  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting

  Selection.Find.Replacement.Font.Italic = True
  With Selection.Find
    .Text = "et al"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  Selection.Find.Execute Replace:=wdReplaceAll


Call Apple


End Sub


Sub Apple()


  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting

  Selection.Find.Replacement.Font.Italic = True
  With Selection.Find
    .Text = "Apple"
    .Forward = True
    .Wrap = wdFindContinue
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With
  Selection.Find.Execute Replace:=wdReplaceAll

End Sub

May I ask how to use just one module to italicise the text "et al" and "apple"?

Thank you.
Reply With Quote