Colors Shapes vs Cells (Excel 2007)

  • Thread starter Thread starter Anthony Berglas
  • Start date Start date
A

Anthony Berglas

There seems to be two different color index schemes in Excel, on for
the cells and one for the shapes. So one cannot write code like

MyCell.interior.colorIndex = MyShape.Fill.ForeColor.SchemaColor

Is there any clean way to convert one to the other? I need the same
color schemes in different places.

(MyDrawingObject.interior.colorIndex was compatible with cells.)

Thanks,

Anthony
 
I,m not sure I understand why ColorIndex = 3 for SchemaColor would be
different than ColorIndex = 3 for Cell.Interior?
 
Add or subtract 7, eg

schemecolor 10 is colorindex 3
(the first 8 starting from zero apply color constants, eg vbRed)

note Charts also use a schemecolor, but these are equivalent to colorindex's
in the range 1-56, with system colours beyond

Regards,
Peter T
 
Thanks for pointing this out. shape --> cell subtract 7 for colors,
and subtract 8 for patterns.

Next problem:-
MyShape.Fill.ForeColor.SchemeColor
works in XL 2003, but not 2007.

The last is a bit worrying. I would have thought that Excel would have
a large suite of regression tests, and that even the quick tests would
test that every property of every object was basically there. By Beta
2 I'm expecting almost production ready, certainly for the old
features. But maybe not.

Does anyone know whether Microsoft actually reads the SAS reports? I
fill out some but suspect that I am wasting my time. They probably
just statistically sample them for keywords from time to time.

Regards,

Anthony
 
and subtract 8 for patterns.

I don't follow, there's no correlation between cell & shape patterns.

Regards,
Peter T
 
I haven't checked all of them but it works for the ones I am interested
in (vert & horizontal stripes etc.)

(Old Style means Cell formats.)

---------- Old Style --------- Pattern
SchemaColor
1 fsProtoSchemaShade 15
8
2 fsProtoRightShade 11
8
3 fsProtoBelowShade 12
8
4 fsProtoSkippedShade 9
8

---------- Shape ForeColor ---------
1 fsProtoSchemaShade 23
15
2 fsProtoRightShade 19
15
3 fsProtoBelowShade 20
15
4 fsProtoSkippedShade 17
15
 
There are 17 cell patterns & 48 shape patterns (excl. solid, none, mixed).
Indeed your +8 conversion seems to apply to the following -

xlPatternChecker:=9 msoPatternSmallCheckerBoard:=17
xlPatternLightHorizontal:=11 msoPatternLightHorizontal:=19
xlPatternLightVertical:=12 msoPatternLightVertical:=20
xlPatternLightDown:=13 msoPatternLightDownwardDiagonal:=21
xlPatternLightUp:=14 msoPatternLightUpwardDiagonal:=22
xlPatternGrid:=15 msoPatternSmallGrid:=23

These patterns also appear similar -

xlPatternGray25:=-4124 msoPattern25Percent:=4
xlPatternGray50:=-4125 msoPattern50Percent:=7
xlPatternHorizontal:=-4128 msoPatternDarkHorizontal:=13
xlPatternVertical:=-4166 msoPatternDarkVertical:=14
xlPatternDown:=-4121 msoPatternDarkDownwardDiagonal:=15
xlPatternUp:=-4162 msoPatternDarkUpwardDiagonal:=16

The other 5 cell patterns do not appear to directly match any of the other
shape patterns

Regards,
Peter T

PS msoPatternHorizontalBrick is 'empty' in my system
 
Hi Anthony,

I gave this one a try in the most current builds, and it works well for me:

?ActiveSheet.Shapes(1).Fill.ForeColor.SchemeColor

(returned 49 in my case - that was with a default blue rectangle object)

Cheers,
Dan
Excel Team

Note: We've only got a couple weeks to get bugs filed and fixed, so if I've
requested additional info via email, it'd be great if you can get that to us
ASAP. Please include any necessary sample files, as well as detailed repro
steps so that we can try to reproduce the problem on our side. Also - if
you're emailing me directly (definitely the most efficient at this point)
you'll want to fixup my email address to remove everything after danbatt and
before the @.
 

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

Back
Top