Free Support Forum - aspose.com

How do I get a count of all the OLE objects embedded in a presentation?

I suspect that I need to enumerate all the OleObjectFrame objects in the presentation, but I'm not sure how to get down to that level. My code goes something like this:

Public Overrides Function ItemCount() As Integer

Dim Slide As Slides.Slide

Dim Ole As Slides.OleObjectFrame

Dim I As Integer = 0

For Each Slide In Presentation.Slides

For Each Ole In Slide.Shapes

I += 1

Next

Next

Return I

End Function

This does not work. I see that OleObjectFrame descends from Shape and Picture Frame, but I cannot access the OleObjectFrames directly from the shapes collection.

Can you recommend anything?

Thanks!

Your inner loop will look like this

------------------------------------------------------------------

For Each shp As Shape In Slide.Shapes

If TypeOf shp Is OleObjectFrame Then

I += 1

End If

Next

------------------------------------------------------------------

The code below checks the type of all shapes on first slide, if it is OLEObjectFrame, it prints the message on console.

------------------------------------------------------------------

Dim srcPres As Presentation = New Presentation("c:\srcPPT.ppt")

Dim srcSld As Slide = srcPres.GetSlideByPosition(1)

For Each shp As Shape In srcSld.Shapes

Console.WriteLine(shp.GetType().Name)

If TypeOf shp Is OleObjectFrame Then

Console.WriteLine("It is an OLEObjectFrame")

End If

Next

------------------------------------------------------------------