excel - 对象“形状”的“表格”方法失败 - PowerPoint
问题描述
我有一些代码从 excel 工作表中获取值并将它们粘贴到 powerpoint 中。然后我想格式化这些值:
Dim shp as PowerPoint.Shape
Dim tbl as Table
Dim shp_count as Long
sld.Shapes.PasteSpecial DataType:=ppPasteHTML, DisplayAsIcon:=msoFalse
Application.CutCopyMode = False
shp_count = sld.Shapes.Count
Set shp = sld.Shapes(sld.Shapes.Count)
shp.Name = key & "_Header"
Set tbl = shp.Table
With tbl.Cell(1, 1).Shape.TextFrame.TextRange
.Font.Color = vbWhite
.Characters(1, 11).Font.Bold = msoFalse
End With
请注意,粘贴到 powerpoint 中的这个特殊形状只是一个单元格。
当我自己运行它时,它工作正常。但是,当另一个用户尝试在他们的机器上运行完全相同的代码时,我收到“对象‘形状’的‘表’方法失败”错误。知道为什么或更好的方法来做这件事吗?
解决方案
也许其他用户的电脑没有你的那么快,粘贴形状需要更多时间?尝试添加
DoEvents
行前:
Set tbl = shp.Table
推荐阅读
- java - 在 Java 中创建包含大文件的目录
- git - 在 monorepo 中限制用户的访问权限
- javascript - 未捕获的 ReferenceError:未定义函数。在 rails6 中使用 webpack 的 HTMLButtonElement.onclick
- php - 类 stdClass 的 Laravel 对象无法转换为字符串。使用 toArray() 时仍然是对象;
- php - 未定义的属性:代理:: (Opencart 2.3)
- reactjs - React Select Tag :: 根据另一个选择更改选择选项
- vue.js - 如何在 Vue-Tables-2 中实现删除数据?
- postgresql - 从 SQL Server 到 Postgres
- ios - iOS:应用程序正在将数百个空相册生成到照片应用程序中
- asp.net - 2 层列表框的体系结构帮助