0

I am accessing a ppt template in C# and creating a custom output programatically based on data.

Microsoft.Office.Interop.PowerPoint.Presentations objPresSet = null;
Microsoft.Office.Interop.Graph.Chart chart = null;
Microsoft.Office.Interop.Graph.DataSheet dataSheet = null;

objPres = objPresSet.Open(@"C:\Sample PPT application\WebSite4\WebSite4\2_Soundbite1.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Microsoft.Office.Interop.PowerPoint._Slide objSlide = null;
objSlide = objPres.Slides[1];



foreach (Microsoft.Office.Interop.PowerPoint.Shape prefixShape in objSlide.Shapes)
{
    chart = (Microsoft.Office.Interop.Graph.Chart)prefixShape.OLEFormat.Object;
    dataSheet = chart.Application.DataSheet;
}

Now in case, when the template is of type '.ppt' then OLEFormat.Object as used above do exist, where as in case of '.pptx', it gives the following error

OLEFormat (unknown member) : Invalid request. This property only applies to OLE objects.

Not able to recognize it, I have searched msdn as well as other sites but no one is distinguishing '.ppt' and '.pptx'.

In the link Creating PowerPoint presentations programmatically , its mentioned that we can write a powerpoint programmatically, the problem I am facing is, I am able to do the same when the extension is '.ppt' whereas in case of '.pptx', I am unable to access charts and graphs being used in the template as the OLEFormat.Object that is used in accessing charts is not working in case of '.pptx', am I missing some dll for '.pptx' support, I am currently using 'Assembly Microsoft.Office.Interop.PowerPoint.dll, v2.0.50727'

Community
  • 1
  • 1
  • Possible duplicate of [Creating PowerPoint presentations programmatically](http://stackoverflow.com/questions/478838/creating-powerpoint-presentations-programmatically) – Mostafiz Apr 25 '16 at 12:00
  • In the above link, its mentioned that we can write a powerpoint programmatically, the problem I am facing is, I am able to do the same when the extension is '.ppt' whereas in case of '.pptx', I am unable to access charts and graphs being used in the template as the OLEFormat.Object that is used in accessing charts is not working in case of '.pptx', am I missing some dll for '.pptx' support, I am currently using 'Assembly Microsoft.Office.Interop.PowerPoint.dll, v2.0.50727' – Pankaj Sharma Apr 25 '16 at 12:31
  • Your code doesn't check the type of shape? Is it a chart type or is it a MSGraph chart object. – Shyam Pillai Apr 25 '16 at 16:25

1 Answers1

0
objSlide[1].Shapes["myObjectNameInsideSlide1"].TextFrame.TextRange.Text = "Kiko";

The above code will access the textbox/shape inside the slide 1

zawhtut
  • 8,335
  • 5
  • 52
  • 76