粘贴范围从 Excel 到 Ppt 作为图像

Pasting Range from Excel to Ppt as image

你好有一个代码,可以将范围从 Excel 复制到 Ppt 作为图像。 但是,当我命令它调整左上角的高度宽度时,它并没有这样做,因为锁定纵横比的默认设置。有什么办法可以修改我的代码吗?

将形状的.LockAspectRatio属性设为msoFalse

Option Explicit

Sub ppt()

    Dim PPTApp As PowerPoint.Application
    Dim PPTPres As PowerPoint.Presentation
    Dim PPTSlide As PowerPoint.Slide
    
    Set PPTApp = New PowerPoint.Application
    PPTApp.Visible = True
    Set PPTPres = PPTApp.Presentations.Add
    Set PPTSlide = PPTPres.Slides.Add(1, ppLayoutBlank)

    Range("A1:C10").Copy
    With PPTSlide.Shapes.PasteSpecial(ppPasteMetafilePicture)
        .LockAspectRatio = msoFalse
        .Left = 20
        .Top = 20
        .Width = 400
        .Height = 300
    End With
    
End Sub