Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Just wanted to let you know that I registered today, and your site is fantastic. I found solutions to problems that I have been encountering for months!..."

Geography

Where in the world do Tek-Tips members come from?

Record a Word Macro to change font color

BlueHorizon (Instructor)
2 Aug 12 6:50
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

SkipVought (Programmer)
2 Aug 12 7:58
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,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

BlueHorizon (Instructor)
2 Aug 12 8:14
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

Andrzejek (Programmer)
2 Aug 12 8:21

My crystal ball is working (I guess) smile 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
        .Color = 12611584
        .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

SkipVought (Programmer)
2 Aug 12 8:25
Sure glad we have some Word Guru's.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

macropod (TechnicalUser)
2 Aug 12 18:32
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]

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close