views:

261

answers:

1

Can anyone help me out how I can change the individual color of each series bar using Microsoft Graph PIA in C#?

I have tried multiple ways but nothing works. There is this ChartFormatFill object inside the Series object but it is read only and doesnt allow me to change the color of the bars.

I have also tried recording a macro and then reading its code but for some weird reason the change color instruction doesnt get macroed. There is no code corresponding to it.

Its the same issue with all the charts. I can't programmatically format the chart series.

I am major stuck here. Can anyone help me out?

Thanks

Regards, Muneeb

A: 

Pleas try:

using Graph = Microsoft.Office.Interop.Graph;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

[...]

PowerPoint.Application oPowerPoint = new PowerPoint.Application();

[...]

PowerPoint.ShapeoShape oShape = oPowerPoint.ActiveWindow.Selection.ShapeRange[1];

[...]

Graph.Chart oChart = (Graph.Chart)oShape.OLEFormat.Object;

[...]

Graph.Series serie = (Graph.Series)oChart.SeriesCollection(1);
Graph.Point point = (Graph.Point)serie.Points(1);                 // !!!!!!!!!!
point.Interior.Color = 0x808080;
point = (Graph.Point)serie.Points(2);
point.Interior.Color = 0x800080;

--
peace

Dzwiedziu