本文介绍了何时在VBA中使用TextFrame或TextFrame2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Powerpoint中的示例:



所以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 vs,当我应该使用 TextFrame2

TextFrame2成员被添加到Excel 2007中,并且更好地控制了文本的格式,因为它不是向后兼容的,我建议使用TextFrame对象



我猜也是这样在PPT中适用。


Example, in Powerpoint:

The TextFrame object:

The TextFrame2 object:

So TextFrame2 also refers to ShapeRange object, and it has a few more properties than TextFrame.

I am not really sure when or whether I should use one or the other, for example, to manipulate the text values held in Table cells on a powerpoint slide. Both seem to work, and the following statement returns 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

Is there some definitive guide on when I should use TextFrame vs when I should use TextFrame2?

解决方案

According to Jon Peltier here: http://peltiertech.com/programming-excel-2007-2010-autoshapes-with-vba/

"The TextFrame2 member was added in Excel 2007 and gives better control over the formatting of the text. Because it is not backward compatible, I would recommend using the TextFrame object"

I'm guessing a similar situation applies in PPT.

这篇关于何时在VBA中使用TextFrame或TextFrame2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 12:00