Microsoft PowerPoint: Convert and Replace Image to PNG Format

The following procedures are written according to and tested under PowerPoint 2010 (14.0.7182.5000 64-bit, Office Professional Plus)


Problem:

Image could take a substantial storage space in a PPT file. We can replace EMF format images with compressed PNG or any other desired format.


Solution 1:

This could easily be achieved by the following steps:

  1. Right click on picture, select ‘Save as Picture’. In the dialog box, select desired picture format and save the picture.
  2. Import the picture by either copy-and-paste or going to ‘Insert’ tab -> ‘Images’ group -> ‘Picture’.
  3. Remove the old one and place the new one to the right location.

Solution 2:

When the amount of task gets large, it is better to use macro.

  1. Add macro functionality to the current presentation.
    1. Go to ‘Customize Ribbon’ (Right click on Ribbon, select ‘Customize the Ribbon’).
    2. On the right side of the window, under ‘Customize the Ribbon’, locate and check the ‘Developer’ tab.
    3. Click ‘OK’.
    4. In main window, switch to ‘Developer’ tab. Click ‘Macros’ in the ‘Code’ group.
    5. In the ‘Macro’ dialog box, fill the Macro name as ‘ConvertShapeToPNG’ and click the ‘Create’ button.
    6. In the VBA window, fill in the newly added macro with the code attached at the end of this post.
    7. Close the VBA window, and go back to the main window of slides.
  2. (Optional) Save the slides including the macro. Due to security limitations, the slides has to be saved into a macro-enabled file.
    1. Click ‘Save’, and a prompt saying that you have to save the file as a macro-enabled file type.
    2. Click ‘No’ to refuse to save it as  a macro-free presentation.
    3. Follow the aforementioned instruction to save the file.
    4. (After editing) When done, save the file as macro-free presentation by changing back the file format in ‘Save as’ dialog. Answer ‘Yes’ to the question and the macro is automatically removed.
  3. Add a button in the Ribbon for the macro.
    1. Go to ‘Customize Ribbon’ (Right click on Ribbon, select ‘Customize the Ribbon’).
    2. On the right side of the window, in ‘Choose commands from’, select ‘Macros’. The macro we just added should show up below.
    3. Under ‘Customize the Ribbon’, click ‘New Tab’ and rename the new tab and group as desired.
    4. Drag the macro from the left to the new group.
    5. Click ‘OK’ and return to the main window.
  4. In the slide, select a single picture that you wish to convert. Click the Ribbon button for the macro, and see the change.

 

Reference:

Stack Exchange: How to convert multiple embedded PNGs to JPEGs in Powerpoint file?

Stack Overflow: Convert internal images in powerpoint to one format

 

(Click “阅读更多” below to get the code)

Sub ConvertShapeToPNG()
 Dim oSh As Shape
 Set oSh = ActiveWindow.Selection.ShapeRange(1)
 oShLeft = oSh.Left
 oShTop = oSh.Top
 
 oSh.Copy
 Set nShRange = ActiveWindow.Selection.SlideRange.Shapes.PasteSpecial(ppPastePNG)
 oSh.Delete
 With nShRange(1)
 .Left = oShLeft
 .Top = oShTop
 End With
 
End Sub

 

Advertisements
  1. 留下评论

Log in or fill out contact info to leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: