Results 1 to 5 of 5

Thread: [RESOLVED] Excel RGB colour numbers different between Excel 2007 and Excel 2010

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Resolved [RESOLVED] Excel RGB colour numbers different between Excel 2007 and Excel 2010

    Hi,

    Part of my VB.NET app reads the colour of a VB.Net chart and applies that same colour to a matching Excel chart:

    Code:
    arrChart_Colour(byteChart_Number) = embchartHTCD.ChartAreas(0).BackColor
    With arrChart_Colour(byteChart_Number)
        xlchartSingle_Chart.ChartArea.Format.Fill.BackColor.RGB = RGB(.R, .G, .B).ToString
    Now all this works fine when I update Excel 2007 charts, but all the colours are wrong with Excel 2010 charts.

    I know the RGB colour numbers are somehow different between the 2 versions of Excel as have run into the same problem before with VBA.

    I only use a few different colours, so I could just have a case statement to change the colour numbers if I'm using Excel 2010, but I'm hoping that there is a better way of doing this.
    Any Ideas?

    Thanks

    Kristian

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Excel RGB colour numbers different between Excel 2007 and Excel 2010

    Hello,

    There is really no better method since there are no functions which spans versions of Excel to keep the same color in the realm of compatibility between two versions of Excel.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Excel RGB colour numbers different between Excel 2007 and Excel 2010

    I've never looked at this, but it really surprises me. Colors are just 32-bit integers with each byte holding a value for one of the three colors (plus the first byte being the alpha, if it is even included). An RGB value with a certain level for Red, a certain level for Green and a certain level for Blue should be just that across all systems or chaos would ensue. How would the program know that in one case, 255,0,0 should be bright red, but in some other program it should be hot pink?

    I could vaguely understand if some named color got a different name in some other program, but an RGB value should be an RGB value across all systems.

    Have you gone looking online for some explanation for this change?
    My usual boring signature: Nothing

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Excel RGB colour numbers different between Excel 2007 and Excel 2010

    Here are two threads I thought would be relevant but are not vb.net yet shed light on the color issue between versions

    http://stackoverflow.com/questions/2...2007-and-later
    http://stackoverflow.com/questions/2...color-property

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Re: Excel RGB colour numbers different between Excel 2007 and Excel 2010

    Hi,
    Thanks for the replies - I was hoping I was just doing it wrong. Interestingly, If I load an Excel 2010 spreadsheet which ended up with the wrong colours into Excel 2007 then the colours are still wrong. If I load up the Excel 2007 spreadsheet into Excel 2010 then the colours are right, so Excel seems to know what it's doing, but driving Excel via VB.NET or VBA gets more complicated. I can't complain too much about these little features as it things like this that make my job more colourful!

    Kristian

Tags for this Thread

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