Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert internal images in powerpoint to one format

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.

like image 872
Tsaukpaetra Avatar asked Nov 19 '25 23:11

Tsaukpaetra


1 Answers

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.

like image 101
Steve Rindsberg Avatar answered Nov 21 '25 14:11

Steve Rindsberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!