VBA powerpoint:在一张幻灯片上调整大小并对齐2张图像

时间:2016-08-31 13:48:33

标签: vba powerpoint-vba

我正在尝试将两张图片调整大小并排并排...在一张幻灯片上比较前后的想法。图片已导入幻灯片。我根据所选的形状编写了两个宏,一个用于左边的一个宏,但是它正在寻找合并为一个。

这是我(新人)要结合的内容

'Updated Macro 
Sub SidebySide()
Dim oSp As Shape
Dim oSld As Slide

If CheckIsPic(oSp) = True Then
With oSp
    Do
        .Height = (5.6 * 72)
        .Width = (4.8 * 72)
        .Left = (0.2 * 72)
        .Top = (1.3 * 72)
    Loop While oSp = ActiveWindow.Selection.ShapeRange(1)
End With

With oSp
    Do
            .Height = (5.6 * 72)
            .Width = (4.8 * 72)
            .Left = (5# * 72)
            .Top = (1.3 * 72)
    Loop While oSp <> ActiveWindow.Selection.ShapeRange(1)
End With

End If

End Sub

Function CheckIsPic(oSp As Shape) As Boolean
If oSp.Type = msoPicture Then CheckIsPic = True
End If
End Function

它没有运行,所以我知道我可能有一些错误,但基本上我试图运行一个循环,如果它是幻灯片上的图片...做A选择,做B到非选择

有什么想法吗?我相信有更好的方法来解决这个问题。感谢

1 个答案:

答案 0 :(得分:0)

我认为将With移到Do...Loop以外会解决问题。 (做两次)

With oSp
    Do
        .Height = (5.6 * 72)
        .Width = (4.8 * 72)
        .Left = (0.2 * 72)
        .Top = (1.3 * 72)
    Loop While oSp = ActiveWindow.Selection.ShapeRange(1)
End With
相关问题