#1
|
|||
|
|||
".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 |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
Hi Paul,
Thank you for the code. Working great! Cheers! |
|
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 |
How to choose a "List" for certain "Heading" from "Modify" tool? | Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |