3
votes

I see a lot of hints and tips on how to export whole slides from a powerpoint presentation into images, but This is not my quest. Instead, I'm trying to convert all of the "non-open-format" image types inside the individual slides and replace them (in place) with their friendly equivalents. This mostly comes up from Google Docs not understanding the .emf and .wmf formats (why? then Open Source software actually does support it?) and since manually exporting the graphics as an image file and re-inserting it into the presentation is a very convoluted process, I was wondering if anyone had found a good way to do this.

So, summary: In place upgrade of emf and wmf files in powerpoint presentations to png or jpg format. As a side note, I can open up these files as a zip file and see the files in question are just in \ppt\media , but simply replacing the files results in Powerpoint just deleting the previously referenced image file and complaining that something might be wrong.

1
.wmf = windows metafile. it's somewhat like PDF in that it's a script to define an image, and not just a list of pixels/colors.Marc B

1 Answers

1
votes

For each "unfriendly" picture, copy and paste it as PNG (or JPG or whatever you want) then delete the original.

Simplistic example:

Sub ConvertShapeToPNG()
    Dim oSh As Shape
    Set oSh = ActiveWindow.Selection.ShapeRange(1)
    oSh.Copy
    ActiveWindow.Selection.SlideRange.Shapes.PasteSpecial ppPastePNG
    oSh.Delete
End Sub

In practice, assuming you want to do this en masse rather than manually one at a time, you'd need a way of deciding whether the picture is "friendly" or not (and in fact whether it's a picture).

You could first check whether oSh.Type = msoPicture (or one of several other possible types). If it's a picture, is it already a raster format or an "unfriendly" format? Try ungrouping a copy of the shape. If the attempt throws an error, it's already raster; if no error, delete the resulting ungrouped shape/shaperange and the copy of the original shape.

Once you've copy/pasted as PNG/etc, you'll need to pick up the x/y position of the original shape, apply that to the new PNG shape and possibly move the new shape to the original's z-order.