Chart objects from C#

  • Thread starter Thread starter Mogur
  • Start date Start date
M

Mogur

Hello all,

I am having problems accessing a Chart object from C#. I guess this is
related to my project's configuration...

I am developing a PowerPoint Add-In using Visual Studio 2008 and C#. The
Add-in inspects the slides of the current presentation when asking to do so,
and access to different properties of their shapes.

And I wanted to access to the properties of the graph the user has
created. I have managed to get a Shape reference that, being a Placeholder,
has a chart (the HasChart property is msoTrue, and the contained object of
the placeholder is a msoChart).

However, I cannot access to the Shape's Chart property. The simple access
to the Chart property of my shape generates a compiler error.

It is quite a bit frustrating because I know that the chart is there: I
could access to its properties from VB (in other different project) and I can
even see it while debugging the project in C#!!! The inspection of the object
properties at debug time shows me the Chart property and all its fields.

I guess this is something related to my project configuration, but I have
no clue about what I am doing wrong.

I am using

using PowerPoint = Microsoft.Office.Interop.PowerPoint
using Excel = Microsoft.Office.Interop.Excel

and my project references among others:

Microsoft.Office.Interop.Excel 12.0
Microsoft.Office.Interop.PowerPoint 12.0
Microsoft.Office.Tools.Common.v9.0
Microsoft.Office.Tools.v9.0
Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0
office 12.0.0.0

Thank you in advance!
 
Thanks for your response.

I have PPT 2007 SP2, and Visual Studio 2008 SP1, so it seems that this is
not the problem...

If I inspect the Microsoft.Office.Interop.PowerPoint assembly (version
12.0.0.0), the Shape interface does not have any Chart property. But I have
not found any newest version of the interop assemblies.

Best regards,
 
Thanks for your response.

I have PPT 2007 SP2, and Visual Studio 2008 SP1, so it seems that this is
not the problem...

If I inspect the Microsoft.Office.Interop.PowerPoint assembly (version
12.0.0.0), the Shape interface does not have any Chart property. But I have
not found any newest version of the interop assemblies.

Best regards,
 
I ran into this same problem when i was trying to extract a chart that was
selected on a slide, couldn't access the chart properties but i knew there
was a chart there.

Anyway to access the chart you have to create a PowerPoint.Chart object
which will store your selected chart.

eg.
Microsoft.Office.Interop.PowerPoint.Chart selectedChart = null;

selectedChart = mySelection.ShapeRange[1].Chart
 
Back
Top