RGB Colours in Excel 2003

D

David Gibbins

Hello,

Strange problem this, I am able to get RGB colours to work in Excel from
Excel VBA.

But when I run the same code from my VB DLL it runs into the 56 colour
palette problem and all the colour go all over the place.

Anybody knows why this is happening?

please remove nospamplease from email address

Regards

David
 
P

Peter T

Hi David,

Not quite sure what you are doing. However most "things"
in Excel can only be formatted with an index that relates
to a particular position on the palette, ie a ColorIndex.
The format then displays whatever colour is currently
assigned to this index.

If you apply an RGB colour, Excel will calculate (with a
not very good algorithm) the best match of the palette
colours, then apply the ColorIndex to which this closest
colour is assigned to.

As the palette only contains 56 colours, the chances of
one being the same as any of the 16,777,216 possible
colours you might be trying to apply is remote (unless one
of the "common" colours).

If you want to apply a colour that does not exist in the
palette, you need to customize one of the palette colours,
manually or programmatically.

Some things, such as drawing shapes, can be directly RGB
formatted, rather than formatted with a palette colour.

Regards,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top