PDA

View Full Version : change color of a number in a numbered list?



kejo
05-03-2009, 05:21 AM
Hello everybody,

i have many numbered lists like this one:


1. first item
2. second item
3. third item

and want to make red the number of the underlined line, like this:


1. first item
2. second item
3. third item

how can i do this?
i have tried some solutions but none worked.
hope you guys are able to help me.

thanks in advance.

BIRD_FAT
05-03-2009, 06:52 AM
Strange one this - the paragraph mark at the the end of the line is the key as it holds the formatting information for the list number! So, what you need to do is highlight that marker and then choose the red font to make it change the number at the FRONT of the underlined text red!
Weird world, huh!

The below code finds the first character with underlining, moves to the next paragraph marker and turns it red (which turns the number at the beginning red, NOT the text between!)


Sub UnderlineRed()
'
' UndelineRed Macro by Bird_FAT
'
'
Selection.Find.ClearFormatting
Selection.Find.Font.Underline = wdUnderlineSingle
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "*"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Font.Color = wdColorRed
End Sub

kejo
05-03-2009, 07:03 AM
ok your code works in office 2007 (only).

btw how do i loop that code until the end of file?
i have many numbered lists to process....

thanks

BIRD_FAT
05-03-2009, 07:49 AM
ok your code works in office 2007 (only).

Should work in any version of office, as far as I know!


btw how do i loop that code until the end of file?
i have many numbered lists to process....

Change the last bit to


Do While Selection.Find.Execute
Selection.Font.Color = wdColorRed
Loop

BIRD_FAT
05-03-2009, 12:14 PM
So, did it work?