Any VBA code to align the picture from PowerPoint?

◇◆丶佛笑我妖孽 提交于 2019-12-08 08:55:55

问题


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

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


回答1:


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.



来源:https://stackoverflow.com/questions/34432550/any-vba-code-to-align-the-picture-from-powerpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!