Opening an embedded Excel file in Powerpoint via C#

G

Guest

I am working with the new 2007 pptx file format. What I have found is that
creating my own presentations from a template, if I use a slide that already
has an embedded excel sheet in it, there is a emf thumbnail of the
spreadsheet that needs to be updated. I have no way of doing this.

That lead me to using the 2007 Interop COM for PowerPoint to somehow get the
powerpoint application to refresh the images on each slide. My theory is to
open the excel files and hope this does the trick.

I have isolated the embedded file with this code:

foreach (Slide s in presentation.Slides)
{
foreach (Microsoft.Office.Interop.PowerPoint.Shape shape
in s.Shapes)
{
if (shape.Type == MsoShapeType.msoEmbeddedOLEObject
&& shape.OLEFormat.ProgID == "Excel.Sheet.12")
{
Microsoft.Office.Interop.Excel.Workbook xl =
(Microsoft.Office.Interop.Excel.Workbook)shape.OLEFormat.Object;
}
}
}


The problem is I get a COM exception trying to convert the oleobject to an
excel workbook:

Object is not connected to server (Exception from HRESULT: 0x800401FD
(CO_E_OBJNOTCONNECTED))

I have also tried the DoVerbs() method but this returns an exception as well.

Anyone have any ideas or perhaps different strategies as to how to fix this
problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top