任何VBA代码来对齐PowerPoint中的图片?

时间:2015-12-23 09:37:54

标签: vba powerpoint powerpoint-vba

我有一张包含239张幻灯片的PowerPoint文档。我必须对齐每张幻灯片中的图片,并执行以下两个步骤:

1。右键单击并选择编辑图片

2. 然后按

enter image description here

enter image description here

我的问题:是否有任何宏(vba代码)可以自动完成所有这些工作? 谢谢!

1 个答案:

答案 0 :(得分:2)

Microsoft以WMF或EMF格式存储复杂的矢量对象,为了编辑它们,需要将它们转换为本机MSO绘图对象(矢量)。执行此操作的过程是取消组合它们,此代码将为您的整个演示文稿执行此操作:

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

如果您需要/需要,可以再次取消组合。