首页 > 解决方案 > Mac - 通过 VBA 将图表从 Excel 复制/粘贴到 Powerpoint (Excel/PPT V.16.35)

问题描述

您好我正在尝试从 Excel 工作表中复制图表并将它们粘贴到 Powerpoint 幻灯片中。我尝试了两种在 VBA 中实现它的方法。

1.Option: failed - 不支持属性或方法> PasteSpecial。

For i = 1 To 10
    ppFile.Slides(i + 1).Select

    Worksheets("Darstellung").ChartObjects(i).CopyPicture

    Set objShape = ppFile.Slides(i + 1).Shapes.PasteSpecial(Datatype:=ppPasteDefault)'<<< problem in this line

With objShape
    .LockAspectRatio = msoFalse
    .ScaleWidth 1.5, msoTrue
    .ScaleHeight 1.9, msoFalse


    .Top = 100
    .Height = 350
    .Width = 700
    .Left = 150
End With

Set objShape = Nothing

Next

2.选项:半失败 - 工作但需要 1 分半钟来粘贴一个图表并在每个图表之后抛出异常:“excel 正在等待另一个应用程序完成 ole 操作”。单击确定让 VBA 运行并粘贴下一个图表。

For i = 1 To 10
    ppFile.Slides(i + 1).Select

    Worksheets("Darstellung").ChartObjects(i).CopyPicture

    Set objShape = ppFile.Slides(i + 1).Shapes.Paste '<<< problem in this line

With objShape
    .LockAspectRatio = msoFalse
    .ScaleWidth 1.5, msoTrue
    .ScaleHeight 1.9, msoFalse


    .Top = 100
    .Height = 350
    .Width = 700
    .Left = 150
End With

Set objShape = Nothing

Next

有什么方法可以在 Mac 上实现它,让它运行正常且高效吗?

标签: excelvbapowerpoint

解决方案


推荐阅读