示例,在 Powerpoint 中:
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.
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/