Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Chart Color (XP)

    Hi all,
    I'm trying to keep colors consistent within all my work. Have custom colors defined and VBA code to copy colors from PERSONAL to new workbooks.

    I've got another program that uses Excel to for embedded charts. It calls on a specific workbook and macro. The workbook has my colors defined, but the chart seems to be Excel default colors. Not good.

    I understand the number scheme for the main color block, but if I want to "hard code" the 8 chart color definitions into VBA, how do I reference them?

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Chart Color (XP)

    Changing the color Palette ONLY changes it for that workbook. It still uses the color index scheme, though it now looks in you CUSTOM Palette to get the definition. If you give that file to anyone else, it will use THEIR palette.

    You would have to replace their palette with yours to get your color scheme. If it is only an issue for you and all the files you create, you can change the DEFAULT Workbook settings (book.xlt in XLStart) to include your color palette on all new workbooks.

    If you want to change the color scheme for others, you should change the colors in the chart objects to NOT refer to the palette, but to use the color property and define it with the RGB function:

    MyObject.Color = RGB(255, 0, 0)

    This will turn "myObject" red. You can make any color you want from the rgb values.

    Steve

  3. #3
    New Lounger
    Join Date
    Oct 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Chart Color (XP)

    Thanks for the reply.

    The issue however is not with workbooks. It is about a chart that is built by a third party program, and somehow evades my attempts at making it use a custom color pallete.

    The chart is already being customized by VBA, so what I'd like to do is code my custom colors into the macro. It seems that I could go your route and define for each chartsegment.color=RGB(0,0,0,)

    OR I could try to set the default chart colors for the book that is being created. This seems more reasonable to me because I never know how many chart segments there will be. But I don't know how to reference the "chart fills" colors or the "chart lines" colors.

    Jay

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Chart Color (XP)

    You can copy color settings from one workbook to another in one fell swoop with Workbooks("Target.xls").Colors = Workbooks("Source.xls").Colors where Source.xls and Target.xls must of course be replaced by the actual names of your workbooks.
    If you want to set only the chart colors, colors with index 17 to 24 are the chart fill colors, and 25 to 32 are the chart line colors. So to set the first fill color to red, you'd use ActiveWorkbook.Colors(17) = vbRed.

  5. #5
    New Lounger
    Join Date
    Oct 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Chart Color (XP)

    Thanks.

    Jay

Posting Permissions

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