【问题标题】:Update one of many shapes in powerpoint slide更新PowerPoint幻灯片中的许多形状之一
【发布时间】:2020-08-02 15:17:48
【问题描述】:

我正在尝试使用 Excel 中带有 vba 的 excel 工作表中的复制范围来更新 powerpoint 幻灯片中的许多形状之一。虽然我可以选择形状,但我无法粘贴到其中。下面的代码执行正确。

PowerPointApp.ActivePresentation.Slides(2).Select
PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4").Select

但下面的代码给出“对象不支持此属性/方法”错误。

PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4").Paste

表 4 已经存在于幻灯片中,我需要用新数据更新它,所以我需要删除表 4 然后重新生成它吗?

【问题讨论】:

    标签: excel vba powerpoint


    【解决方案1】:

    表格 4 已经存在于幻灯片中,我需要用新数据更新它,所以我需要删除表格 4 然后重新生成它吗?

    要么删除并重新生成,要么将现有表中的数据替换为新数据。

    如果您创建一个新表,您可能需要编写大量代码来从原始表中提取 z 顺序和格式并将其应用于新表。更改现有表中的数据通常会简单得多。

    顺便说一下,这部分:

    PowerPointApp.ActivePresentation.Slides(2).Select
    PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4").Select
    

    不是最好的方法。如果不是绝对必要,永远不要选择任何东西,在这种情况下它不是。

    改为:

    With PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4")
       ' do stuff
    End With
    

    Dim oTbl as Object
    Set oTbl = PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4")
    With oTbl
       ' do stuff
    End With
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-16
      • 1970-01-01
      • 2017-12-30
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多