【问题标题】:Any VBA code to align the picture from PowerPoint?任何 VBA 代码来对齐 PowerPoint 中的图片?
【发布时间】:2015-12-23 09:37:54
【问题描述】:

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

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

2.然后按YES

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

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    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
    

    如果您愿意/需要,您可以再次取消分组。

    【讨论】:

    • 一个问题,请。该代码正在运行,但是为什么此代码会复制幻灯片中的所有图表并将其放入我按下单击的一张幻灯片中?谢谢!
    • 我不确定我是否理解 luli。代码不应该复制任何东西。它只是遍历所有幻灯片的所有形状,并尝试取消任何“图片”类型的组合。你怎么称呼潜艇?
    猜你喜欢
    • 1970-01-01
    • 2019-11-11
    • 2017-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-24
    • 2012-07-17
    • 1970-01-01
    相关资源
    最近更新 更多