Microsoft Office Development and Consultancy
 Home|

Excel

|VBA|C#|Finance|Tools|Newsletter|Feedback|Contact 
 Excel > Charts > VBA Code > Formatting< Previous | Next > 

 

Interior

 
 

There are two ways you can assign a particular colour to the interior of a series.

 
 

You can either use the .ColorIndex property or the .Color property.

 
 

You should always use the Colorindex and never the Color

 
 

The reason for this is because the Color property is not accurate

 
 

If you assign a colour that is not on the colour palette then it will not be assigned

 
 

Excel will scan the colour palette and will assign a colour from the colour palette which it thinks is the closest match.

 

 

This is not a problem in 2007 as the chart colours can be completely independent from the active theme.

 


 

ColorIndex not Color

 
 

Another reason you should always use the colorindex property in 2003 is because the automatic conversion from colour to colorindex is not 100% accurate

 

 

For example if you add the colour RGB(69,85,96) to the colour palette and then assign this colour using RGB it will actually use colorindex (5) instead and not the colour you specified.

 


 

Fonts

 
 

There is not a single line of code that will change the font of the whole chart (ie for all the different chart elements)

 

 
1
objChart.ChartArea.Font.Size = 10
   

 

This does not appear in the intellisense

 
 
2
objChart.Legend.Font.Size = 10
   

 
3
4
objAxis.TickLabels.Font.Size = 10
objAxis.AxisTitle.Characters.Font.Size = 10
   





 © Better Solutions Limited 10-May-2013< Previous | Top | Next >