Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record a Word Macro to change font color

Status
Not open for further replies.

BlueHorizon

Instructor
Joined
Jan 16, 2003
Messages
730
Location
US
Good morning all,
In Word 2010, I've tried recording a font formatting macro that includes changing the font color. When I run the macro, it performs all actions except the font color change. Is this new in 2010? Is there something different I need to do to make the font color change become part of the recorded macro?
Thanks,
KV

Best,
Blue Horizon [2thumbsup]
 
hi,

My crystal ball is not working, so I cannot see the code to which you refer.

Did the font color change when you recorded the macro?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
No crystal ball necessary, Skip. The question was generic to Word macros. It seems I cannot get a font color change to work when I record a macro. I wanted to know if it was a problem with new 2010 macros or if it was a problem on my load of Word.

Thanks anyway,
K

Best,
Blue Horizon [2thumbsup]
 

My crystal ball is working (I guess) :-) and when I type a text and select a word and change the color from the ribon, I just get:

Code:
Sub Macro2()
    Selection.TypeText Text:="This is a test"
    Selection.MoveLeft Unit:=wdCharacter, Count:=4, Extend:=wdExtend
End Sub

and, of course, the color does not change.

But, if I do pretty much the same, but I click on the Home - Font (Ctrl-D) group which brings me the dialog with Font / Advanced tabs and use it while recording my macro, I get:

Code:
Sub Macro3()
    Selection.MoveLeft Unit:=wdCharacter, Count:=4, Extend:=wdExtend
    With Selection.Font
        .Name = "+Body"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False[blue]
        .Color = 12611584[/blue]
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
End Sub

Have fun.

---- Andy
 
Sure glad we have some Word Guru's.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
As a rule, it is better practice to create/modify an appropriate Style than to use hard formatting to change paragraph/font attributes.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top