【问题标题】:Pasting Range from Excel to Ppt as image将范围从 Excel 粘贴到 Ppt 作为图像
【发布时间】:2021-11-20 16:27:38
【问题描述】:

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

【问题讨论】:

  • 请不要提供代码图片,edit 问题和格式为代码块。
  • 宏在 Excel 还是 Powerpoint 中?
  • 这是一个excel宏

标签: excel vba powerpoint


【解决方案1】:

将形状的.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

【讨论】:

    猜你喜欢
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    相关资源
    最近更新 更多