PDA

View Full Version : Solved: Change Font Color in Text String



mphill
01-22-2013, 03:13 PM
Hi,

I was wondering how to change the font color of a line of text in the middle of the words. I did find a 'Selection.Font.Color = wdColorRed' after running a macro but would like to confirm that syntax, since I did highlight\select the text.

Here is the original line of text (in black) and I would like the underscore to be red.



r.InsertAfter (" , P.E., Resident Engineer, ________________")


Would I break up the text like below?


r.InsertAfter (" , P.E., Resident Engineer,") & Font.Color=wdColorRed (" ________________") Font.Color=wdColorBlack


Thanks for your help.

gmaxey
01-22-2013, 03:23 PM
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim r As Word.Range
Set r = Selection.Range
r.Text = " , P.E., Resident Engineer, ________________"
r.Collapse wdCollapseEnd
r.MoveStartUntil Cset:=" ", Count:=wdBackward
r.Font.Color = wdColorRed
End Sub

mphill
01-23-2013, 08:20 AM
Thank you for the sample code.