Example, in 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.
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.
In addition, TextFrame
doesn't contain the property LanguageID
in macOS, so you're forced to use TextFrame2
. Be aware of that if you're working with that property in a cross-platform environment. I faced that problem in the past.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With