I am using Aspose.Slides to extract an ole embedded object from a powerpoint presentation file. It does not work properly when I have an powerpoint file embedded inside another powerpoint file. It works when a embedded object is a word or an excel.
It actually creates a file for the powerpoint ole object and has all the contents of the object but the file does not get saved with a ppt extension because the OleObjectFrame.ObjectType value is "Unknown" instead of a "PowerPointPresentation".
Please check the sample file attached.
This is my code
Presentation pres = new Presentation(path);
int filenum = 0;
foreach(Slide slide in pres.Slides)
{
foreach (Aspose.Slides.Shape shape in slide.Shapes)
{
filenum += 1;
if (shape.ToString().Contains("OleObjectFrame"))
{
string fileName = @"C:\temp\testAsposeSlides" + filenum + ".";
OleObjectFrame oleOF = shape as OleObjectFrame;
switch (oleOF.ObjectType)
{
case OleObjectType.PowerPointPresentation:
fileName += "ppt";
break;
case OleObjectType.MicrosoftExcel:
fileName += "xls";
break;
case OleObjectType.MicrosoftWordTable:
fileName += "doc";
break;
default:
break;
}
FileStream fstr = new FileStream(fileName, FileMode.Create, FileAccess.Write);
byte[] buf = oleOF.ObjectData;
fstr.Write(buf, 0, buf.Length);
fstr.Flush();
fstr.Close();
}
}
}
Thanks