excel - 更新PowerPoint幻灯片中的许多形状之一
问题描述
我正在尝试使用 excel 表中的 vba 复制范围来更新 powerpoint 幻灯片中的许多形状之一。虽然我可以选择形状,但我无法粘贴到其中。下面的代码执行正确。
PowerPointApp.ActivePresentation.Slides(2).Select
PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4").Select
但是下面的代码给出了“对象不支持这个属性/方法”错误。
PowerPointApp.ActivePresentation.Slides(2).Shapes("Table 4").Paste
表 4 已经存在于幻灯片中,我需要用新数据更新它,所以我需要删除表 4 然后重新生成它吗?
解决方案
表 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
推荐阅读
- html - Angular 11 错误:无法绑定到“ngForOf”,因为它不是“tr”的已知属性
- bash - bash 脚本问题(引用问题?)找不到 smbclient 命令?
- django-rest-framework - serializer.data 产生异常,如何调试
- reactjs - 当我将任何元素放入依赖数组功能组件中时,无限渲染
- tensorflow - 在tensorflow中读取时如何过滤数据集?
- linux - 为什么 logrotate 复制了一个文件但没有创建一个新文件?
- javascript - NodeJS + Mongodb - 属性隐藏
- git - 在 git 存储库之外保存 git 存储库内容
- javascript - 反应:div上的按键监听器
- rust - 在线程之间发送 Boxed 特征