Excel SQL在PowerPoint中工作以选择和调整图片大小

时间:2018-04-27 07:52:55

标签: vba excel-vba powerpoint-vba excel

我在Excel中有这个代码,但是我需要在Powerpoint中使用相同的东西,但我无法让它工作。

Sub Macro1()
    ' Macro1 Macro
    ActiveSheet.Pictures.Insert("C:\Users\BobDylan\Pictures\Prince Symbol.jpg" _
        ).Select
    Selection.ShapeRange.IncrementLeft 45
    Selection.ShapeRange.IncrementTop 27
    Selection.ShapeRange.ScaleWidth 1.2272727273, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 1.2272727273, msoFalse, msoScaleFromTopLeft
    Range("K16").Select
End Sub

1 个答案:

答案 0 :(得分:0)

这是一些让你入门的东西:

ActivePresentation.Slides(1).Shapes.AddPicture "C:\Users\BobDylan\Pictures\Prince Symbol.jpg", msoFalse, msoTrue, 10, 10, 100, 100

<强>更新

在您的问题后添加

Sub test()
    Dim TargetSlide As Slide
    Dim pptLayout As CustomLayout

    Set pptLayout = ActivePresentation.Slides(1).CustomLayout

    Set TargetSlide = ActivePresentation.Slides.AddSlide(ActivePresentation.Slides.Count, pptLayout)
    TargetSlide.Shapes.AddPicture "C:\Users\BobDylan\Pictures\Prince Symbol.jpg", msoFalse, msoTrue, 10, 10, 100, 100
End Sub