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
object 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!
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.
精彩评论