Vba 如何使用Power Point中的宏对齐不同幻灯片上的图片

Vba 如何使用Power Point中的宏对齐不同幻灯片上的图片,vba,powerpoint,Vba,Powerpoint,我有以下宏,在Power Point中一次对齐1张选定图片: Sub Align() With ActiveWindow.Selection.ShapeRange .Left = 50 .Top = 100 End With End Sub 如果在幻灯片中的选定图片上运行宏,则此代码有效 但是,如何为所有幻灯片的每张图片运行此脚本?这将为您完成以下操作: ' PowerPoint VBA to repositio

我有以下宏,在Power Point中一次对齐1张选定图片:

Sub Align()
      With ActiveWindow.Selection.ShapeRange 
              .Left = 50
              .Top = 100
      End With
End Sub
如果在幻灯片中的选定图片上运行宏,则此代码有效


但是,如何为所有幻灯片的每张图片运行此脚本?

这将为您完成以下操作:

' PowerPoint VBA to reposition all pictures in all slides in a deck
' Written by Jamie Garroch of YOUpresent Ltd.
' http://youpresent.co.uk/

Option Explict

Sub RepositionAllPictures()
  Dim oSld As Slide
  Dim oShp as Shape
  For Each oSld in ActivePresentation.Slides
    For Each oShp in oSld.Shapes
      If oShp.Type = msoPicture Then RepositionShape oShp
      If oShp.Type = msoPlaceholder Then
        If oShp.PlaceholderFormat.ContainedType = msoPicture Or _
           oShp.PlaceholderFormat.ContainedType = msoLinkedPicture Then _
             RepositionShape oShp
      End If
    Next
  Next
End Sub

Sub RepositionShape(oShp As Shape)
  oShp.Left = 50
  oShp.Top = 100
End Sub

你好,杰米。建议编辑:同时检查msoLinkedPicture