Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2015, 06:30 AM
rsrasc rsrasc is offline ".Replacement.Font.Color" Possible Combination Windows 7 64bit ".Replacement.Font.Color" Possible Combination Office 2010 64bit
Competent Performer
".Replacement.Font.Color" Possible Combination
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default ".Replacement.Font.Color" Possible Combination

Hi all,




Code:
Sub FormatLetterA()
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
        .Text = "Answer (A) "
        .Replacement.Text = ""
        .Replacement.Font.Bold = True
        .Replacement.Font.Italic = False
        .Replacement.Font.Color = 12611584
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWholeWord = True
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub FormatLetterB()
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
        .Text = "Answer (B) "
        .Replacement.Text = ""
        .Replacement.Font.Bold = True
        .Replacement.Font.Italic = False
        .Replacement.Font.Color = 12611584
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWholeWord = True
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub FormatLetterC()
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
        .Text = "Answer (C) "
        .Replacement.Text = ""
        .Replacement.Font.Bold = True
        .Replacement.Font.Italic = False
        .Replacement.Font.Color = 12611584
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWholeWord = True
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub FormatLetterD()
   Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
        .Text = "Answer (D) "
        .Replacement.Text = ""
        .Replacement.Font.Bold = True
        .Replacement.Font.Italic = False
        .Replacement.Font.Color = 12611584
        .Forward = True
        .Wrap = wdFindContinue
        .MatchWholeWord = True
   End With
   Selection.Find.Execute Replace:=wdReplaceAll
End Sub


I have the above code in a macro and would like know if they could be combined in one.

I tried several options but I couldn't get them to work.

For example, the below code will only highlight the second option (.Text = "Answers (B), (C), and (D)") but not both.

Any help is appreciated. Thanks!!!

Code:
Sub FormatAllLetters()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Answers (A), (C), and (B)"
.Replacement.Text = ""
.Text = "Answers (B), (C), and (D)"
.Replacement.Text = ""
.Replacement.Font.Bold = True
.Replacement.Font.Color = 12611584
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote
  #2  
Old 10-20-2015, 02:23 PM
macropod's Avatar
macropod macropod is offline ".Replacement.Font.Color" Possible Combination Windows 7 64bit ".Replacement.Font.Color" Possible Combination Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 FormatAllLetters()
With ActiveDocument.Range.Find
  .ClearFormatting
  .Text = "Answers \([A-C]\)"
  With .Replacement
    .ClearFormatting
    .Font.Bold = True
    .Font.Color = 12611584
    .Text = "^&"
  End With
  .Forward = True
  .Wrap = wdFindContinue
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-21-2015, 12:44 AM
rsrasc rsrasc is offline ".Replacement.Font.Color" Possible Combination Windows 7 64bit ".Replacement.Font.Color" Possible Combination Office 2010 64bit
Competent Performer
".Replacement.Font.Color" Possible Combination
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Hi Paul,

Thank you for the code. Working great!

Cheers!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Font Color Question//.Replacement.Font.Color = 12611584 rsrasc Word VBA 3 09-05-2015 09:03 PM
Setting Font Color and Style "permanently" wings1080 Word 5 12-19-2014 08:44 AM
Is there a way to change "Genesis" Theme Color from Blue to Green FUNKSTICK PowerPoint 13 03-12-2014 12:29 AM
How to globally change default "pattern fill" color for all shapes in PP 2013 tbach PowerPoint 1 01-31-2014 10:59 AM
".Replacement.Font.Color" Possible Combination How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:29 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