Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2023, 07:20 AM
syl3786 syl3786 is offline Simple issue: formatting mroe than one text just using one module Windows 10 Simple issue: formatting mroe than one text just using one module Office 2019
Advanced Beginner
Simple issue: formatting mroe than one text just using one module
 
Join Date: Jan 2023
Posts: 78
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
  #2  
Old 10-12-2023, 09:04 AM
vivka vivka is offline Simple issue: formatting mroe than one text just using one module Windows 7 64bit Simple issue: formatting mroe than one text just using one module Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 10-13-2023, 03:18 AM
syl3786 syl3786 is offline Simple issue: formatting mroe than one text just using one module Windows 10 Simple issue: formatting mroe than one text just using one module Office 2019
Advanced Beginner
Simple issue: formatting mroe than one text just using one module
 
Join Date: Jan 2023
Posts: 78
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
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

It works well! Many thanks for your help!
Reply With Quote
  #4  
Old 10-13-2023, 08:47 AM
vivka vivka is offline Simple issue: formatting mroe than one text just using one module Windows 7 64bit Simple issue: formatting mroe than one text just using one module Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

I'm glad that you are glad!
Reply With Quote
Reply



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
Simple issue: formatting mroe than one text just using one module 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft