none
Getting image from PowerPoint msoPicture object RRS feed

  • Question

  • I want to get image from the selected msoPicture in PowerPoint. I.e. 

    Dim _pic As Image
            _pic = Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange(1) 'given ShapeRange(1).Type = msoPicture

    Any ideas on how to do this?

    Sunday, August 24, 2014 7:51 PM

Answers

All replies

  • Hello,

    You can:
    1. Use the Copy method to copy the image to the clipboard and then access it using the Clipboard class from the .Net framework BCL.
    2. Use the Export method of the Shape class.
    3. Use Open XML SDK to extract the data (see OpenXMLDeveloper.org and the Open XML SDK forum).

    See PowerPoint - How to access a Picture's color information for more information.

    Sunday, August 24, 2014 8:25 PM
  • I have found it useful to look for pictures that are contained within a placeholder object and are just inserted simply into the the slide. In addition, you have to look at how the picture has been inserted as either a linked image or an embedded one. Here is code that is looking for the pictures, copying them, and then pasting the copied image into a Word document. Obviously there are other outcomes that your particular application might be trying to accomplish, but the basic process of locating the picture object within the slide remains the same.

        For Each shp In sld.Shapes
            If shp.type = Office.MsoShapeType.msoPicture Or _
                shp.type = Office.MsoShapeType.msoLinkedPicture Then
                shp.Copy
                rng.InsertParagraphBefore
                rng.MoveStart Word.WdUnits.wdParagraph, Count:=1
                rng.Paste
                rng.Collapse (Word.WdCollapseDirection.wdCollapseEnd)
            ElseIf shp.type = Office.MsoShapeType.msoPlaceholder Then
                shp.Copy
                If shp.PlaceholderFormat.ContainedType = Office.MsoShapeType.msoPicture Or _
                     shp.PlaceholderFormat.ContainedType = Office.MsoShapeType.msoLinkedPicture Then
                    If shp.HasTextFrame = Office.MsoTriState.msoFalse Then
                        rng.InsertParagraphBefore
                        rng.MoveStart Word.WdUnits.wdParagraph, Count:=1
                        rng.Paste
                        rng.Collapse (Word.WdCollapseDirection.wdCollapseEnd)
                    End If
                End If
            End If
        Next
    
    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com

    Monday, August 25, 2014 2:00 AM