excel - 何时在 VBA 中使用 TextFrame 或 TextFrame2

标签 excel vba powerpoint

示例,在 Powerpoint 中:

The TextFrame object:

Represents the text frame in a Shape object. Contains the text in the text frame and the properties and methods that control the alignment and anchoring of the text frame.

The TextFrame2 object:

Represents the text frame in a Shape or ShapeRange object. Contains the text in the text frame and exposes properties and methods that control the alignment and anchoring of the text frame.

所以TextFrame2也引用了ShapeRange对象,并且它比TextFrame多了一些属性。

我不太确定何时或是否应该使用其中之一,例如,操作 powerpoint 幻灯片上表格单元格中保存的文本值。两者似乎都有效,并且以下语句返回 TRUE

Dim tbl as Table
Set tbl = ActivePresentation.Slides(1).Shapes("Table1").Table

tbl.Cell(r, c).Shape.TextFrame2.TextRange.Characters.Text = _
    tbl.Cell(r, c).Shape.TextFrame.TextRange.Characters.Text

是否有关于何时应该使用 TextFrame 以及何时应该使用 TextFrame2 的明确指南?

最佳答案

根据 Jon Peltier 的说法:http://peltiertech.com/programming-excel-2007-2010-autoshapes-with-vba/

“TextFrame2 成员是在 Excel 2007 中添加的,可以更好地控制文本格式。由于它不向后兼容,我建议使用 TextFrame 对象”

我猜 PPT 中也存在类似的情况。

关于excel - 何时在 VBA 中使用 TextFrame 或 TextFrame2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16674028/

相关文章:

vba - 使用范围作为自动筛选方法的标准数组

vba - excel-vba if 函数消息 "collection is one-based"

c# - C# 中的 PowerPoint 笔记

python - 使用python从多个powerpoint文件中提取文本

vba - 如何向 PowerPoint 2010 添加调用宏的选项卡

vba - For 循环案例选择错误

vba - 循环遍历当前事件工作表中 Excel VBA 中的所有命名范围

excel - 如何将参数传递给 Laravel Excel 的导出文件以进行 DB 查询

vba - `Case` 与 VBA 的 `Select` 语句的目的是什么?

json - 如何正确将JSON导入Excel