![]() |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Hi, try this:
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
.Execute Replace:=wdReplaceAll
.Text = "Apple"
.Execute Replace:=wdReplaceAll
End With
End Sub
|
|
#3
|
|||
|
|||
|
Quote:
It works well! Many thanks for your help! |
|
#4
|
|||
|
|||
|
I'm glad that you are glad!
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Standard Module, Class Module and UserForm | jpl | Word VBA | 0 | 03-14-2022 07:20 AM |
| So simple, it may be hard to explain... (mouse issue) | Jonesey | Excel | 1 | 07-03-2020 11:30 AM |
Restrict Formatting Issue - pasted text changes page size
|
bclear16 | Word | 6 | 08-22-2016 11:31 PM |
| Word Formatting Issue: Space above text when linked to Excel | JDHeisenberg | Word | 3 | 08-19-2016 05:34 AM |
| AZWizard Module - ?hidden module | pcaldwell | Word | 1 | 08-22-2012 01:19 PM |