views:

23

answers:

1

I am trying to access charts in slides in PowerPoint 2007 via VSTO, and I am a bit confused. While the Interop provides a property Shape.HasChart which properly finds shapes that have/are charts, I can't figure out how to access the Chart itself. I don't see a chart property on the Shape. Am I supposed to cast the Shape to a specific type?
Looking into the documentation, it seems that charts were not well supported initially in Office 2007, but it's not clear to me whether there is a way to access the Chart and do things like change the title or the axis. Any pointers would be highly appreciated!

+1  A: 

You need to access the OLEFormat.Object of the Shape.

Graph.Chart aChart = (Graph.Chart) pptSlide.Shapes[1].OLEFormat.Object;
aChart.Activate();

I can do this successfully with Office 2003.

I goggled a bit and apparently with 2007 SP2 there is a way to get a your shape object a .Chart property. I do not have 2007, so I can not test this.

Mark
Thanks for the reply. I had come across the mention to the elusive Chart property, but have yet to find it! It took me a bit to figure out that Chart is in Microsoft.Interop.Graph - still working on getting it to work, but this is a great starting point.
Mathias