Iuli
Iuli

Reputation: 167

Any VBA code to align the picture from PowerPoint?

I have a PowerPoint document with 239 slides. I have to align the picture from every slide making the following two steps:

1. Right click and select Edit Picture

2. Then Press YES

enter image description here

enter image description here

My question: Is there any macro (vba code) to do all this job automatically? Thanks!

Upvotes: 1

Views: 771

Answers (1)

Jamie Garroch - MVP
Jamie Garroch - MVP

Reputation: 2999

Microsoft stores complex vector objects in WMF or EMF formats and in order to edit them one needs to convert them to native MSO drawing objects (vectors). The process to do this is to ungroup them and this code will do it for your entire presentation:

Option Explicit

' ===================================================================
' Purpose : Loop through each shape of each slide in a presentation
'           and ungroup and WMF files, thereby converting them to
'           MSO drawing objects that can be edited.
' Author  : Jamie at YOUpresent Ltd. http://youpresent.co.uk/
' ===================================================================
Sub ConvertAllMetafilePicturestoGroups()
  Dim oSld As Slide
  Dim oShp As Shape
  For Each oSld In ActivePresentation.Slides
    For Each oShp In oSld.Shapes
      On Error Resume Next ' In case picture is a bitmap and not a WMF vector
      If oShp.Type = msoPicture Then oShp.Ungroup
      On Error GoTo 0
    Next
  Next
  ' Clean up
  Set oShp = Nothing: Set oSld = Nothing
End Sub

You can ungroup a second time if you want/need to.

Upvotes: 2

Related Questions