Results 1 to 9 of 9

Thread: Excel/VBA - change font color of object?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Excel/VBA - change font color of object?

    I have a button on a worksheet which runs some VBA code. Most of it works fine but when it comes to a section that is supposed to change the line, fill and font color of an AutoShape ( a rectangle) containing some text, I have a problem. I can change the line color and fill color okay with the following code:

    Code:
    'fill color = tan
    Shapes("test").Fill.ForeColor.SchemeColor = 47
    
    'line color = black
    Shapes("test").Line.ForeColor.SchemeColor = 64
    However, when I programmed in this code for the font color...

    Code:
    Shapes("test").Font.ColorIndex = 0
    ...I get the error message "object doesn't support this property or method".

    I take this to mean that you cannot change the font color, but this must be wrong! How can I change the font color if the object doesn't have the .Font.ColorIndex property?

    If I actually select the object on the worksheet then I can record a macro that will change the color. This is what I get:

    Code:
    Selection.Font.ColorIndex = 0
    But I don't want to have to select the object in order to change the font color.

    What can I do?

    *Edit* I should also mention that the code is within a worksheet code module, not a standard code module.

    Thanks
    -Rob
    Last edited by TheRobster; Sep 30th, 2005 at 05:54 PM.
    http://www.sudsolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width