![]() |
#4
|
||||
|
||||
![]()
For that you could use something based on:
Code:
Sub Demo() Application.ScreenUpdating = False Dim StrFnd As String, i As Long With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Text = "^&" .Forward = True .Format = True .Wrap = wdFindContinue .MatchCase = True .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False StrFnd = "One,Two,Three" For i = 0 To UBound(Split(StrFnd, ",")) .Text = Split(StrFnd, ",")(i) .Replacement.Font.ColorIndex = wdBlue .Execute Replace:=wdReplaceAll Next StrFnd = "Four,Five,Six" For i = 0 To UBound(Split(StrFnd, ",")) .Text = Split(StrFnd, ",")(i) .Replacement.Font.ColorIndex = wdRed .Execute Replace:=wdReplaceAll Next StrFnd = "Seven,Eight,Nine,Ten" For i = 0 To UBound(Split(StrFnd, ",")) .Text = Split(StrFnd, ",")(i) .Replacement.Font.ColorIndex = wdGreen .Execute Replace:=wdReplaceAll Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
macro |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro now fails in Word 2013 after working for more than a year; still works in 2007 | cyraxote | Word VBA | 10 | 09-05-2015 12:33 AM |
Looking for Help to Create a Macro (Sort) | rsrasc | Word VBA | 5 | 04-16-2014 03:25 AM |
![]() |
Baldeagle | Word VBA | 3 | 09-30-2013 03:56 AM |
macro works on windows, not on mac | iiiiifffff | Word VBA | 2 | 04-03-2013 12:42 PM |
![]() |
tinfanide | Excel Programming | 5 | 12-03-2011 12:53 AM |