Aspose.Slides is a file management component that can help you read/write/manipulate the PowerPoint documents.
You can also extract OLE objects from PowerPoint documents using Aspose.Slides. For example, I have attached a sample application here along with solution/project in C#, it basically reads the source ppt and extracts the OLE objects (excel chart and pdf document) from it and write it to C: drives.
Hopefully, it will be helpful for you.
You can ask any of your questions regarding Aspose.Slides from the Aspose.Slides forum.
C# Code
//Read the source ppt file
string sourcePath = @"..\..\..\source.ppt";
Presentation srcPres = new Presentation(sourcePath);
//Get the first slide
Slide sld = srcPres.GetSlideByPosition(1);
//Output file id
int fid = 0;
//Extract all ole objects
foreach (Shape shp in sld.Shapes)
{
//oof will not be null, if shape is ole object frame
OleObjectFrame oof = shp as OleObjectFrame;
if (oof != null)
{
//Check the class
string objName = oof.ObjectClassName;
//decide extension
//if it is excel, set it as .xls
//if it is pdf, set it as .pdf
string ext = "";
if (objName.Contains("Microsoft Excel Chart") == true)
ext = ".xls";
else
if (objName.Contains("Adobe Acrobat 7.0 Document") == true)
ext = ".pdf";
//Now extract the data and write it to file
FileStream fout = new FileStream("c:\\outOLE" + fid + ext, FileMode.Create, FileAccess.Write);
fout.Write(oof.ObjectData, 0, oof.ObjectData.Length);
fout.Close();
//increment fid
fid++;
}
}
I have updated the thread with VB.NET code, which works exactly the same as C# code in previous post.
VB.NET
'Read the source ppt file
Dim sourcePath As String = "..\..\..\source.ppt"
Dim srcPres As Presentation = New Presentation(sourcePath)
'Get the first slide
Dim sld As Slide = srcPres.GetSlideByPosition(1)
'Output file id
Dim fid As Integer = 0
'Extract all ole objects
For Each shp As Shape In sld.Shapes
If TypeOf shp Is OleObjectFrame Then
Dim oof As OleObjectFrame = shp
'Check the class
Dim objName As String = oof.ObjectClassName
'Decide the extension
'if it is excel, set it as .xls
'if it is pdf, set it as .pdf
Dim ext As String = ""
If objName.Contains("Microsoft Excel Chart") = True Then
ext = ".xls"
ElseIf objName.Contains("Adobe Acrobat 7.0 Document") = True Then
ext = ".pdf"
End If
'Now extract the data and write it to file
Dim fout As FileStream
fout = New FileStream("c:\outOLE" & fid & ext, FileMode.Create, FileAccess.Write)
fout.Write(oof.ObjectData, 0, oof.ObjectData.Length)
fout.Close()
'increment fid
fid = fid + 1
End If
Next
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.