Thread: colour palette
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default colour palette

It would help if you just posted what you finally understood rather than you
internal mumblings that got you there. I have just spent ten minutes
double-checking my words and how Excel works because of your opening
statements, which did not reflect what I said. Ten minutes wasted.

I said that you can change the colour, I didn't say you can use any colour
within the spectrum within code.

Excel only has a colour palette of 56 colours, so any colour you try to use
snaps back to one of those as you say. But you can define what those 56
colours are.

And there was no need for the profanity in the light of your later
understanding.

Bob

"Amedee Van Gasse" wrote in message
...
Bob Phillips shared this with us in microsoft.public.excel.programming:


"Amedee Van Gasse" wrote in message
...

I have two additional questions on this subject:

1. Is there some "deep wizardry" to change this programmatically? If
need be with API calls or the casting of elvish runes?


Not sure what you mean by deep wizardy, but you can set a colour
programmatically very easily

Activeworkbook.Colors(3) = RGB(0,0,255)

changes colour 3, which is usually red, to blue. As I am sure that
you can see it can be any hue between white and black by using the
relevant RGB value.


Have you tried this yourself?
At least in Excel 2000, any RGB color you use snaps back to the nearest
color in the 40 color palette.
I tried this with a 3D chart (let's say frequency, amplitude, time). I
wanted to have different shades of the same color, so I had something
like this in my code (from memory):

blablabla(i).Color = RGB(0, 0, Int(255 * i /n))

where i is increased in a loop and n is the number of shades of blue,
obviously.

The result was only 3 shades of blue that happened to be in the
palette. ********.


Duh...
PARSING ERROR DETECTED. BACKTRACING...
|^H\^H-^H/^H|^H\^H-^H/^H|^H\^H-^H/^H|^H\^H-^H/^H|^H\^H-^H/^H|

OK, now I finally understand what you mean.
So essentially I have to do the following:

1. Determine how many shades I need with blablabla.Count
2. A loop with Activeworkbook.Colors(i) = RGB(0, 0, Int(255 * i /n))
3. A loop with blablabla(i).Color = Activeworkbook.Colors(i)

This still needs some polishing, but I can grok the general concept.
Thank you, and May The Force Be With You ;-)

2. Is this a global setting, or per file?


It is per file. The way to make it global is to open Book.xlt from
the start directory and modify that and save it. Any new books then
assume this value.


OK. I need it to be per file. Saving it before changes and restoring it
again when I close the wb really blows.

--
Amedee Van Gasse using XanaNews 1.17.4.1