What are Shape.TextFrame and .TextRange in PowerPoing VBA?

1.8k Views Asked by At

I am looking for information to help me better understand ".TextFrame" and ".TextRange" objects in PowerPoing VBA. Can anybody help? I have reviewed the stuff on MSDN and am just continually disappointed with the documentation there.

1

There are 1 best solutions below

0
On

Shapes are the basic building blocks for PPT slides, masters, layouts, notes pages; everything on them is a shape.

Some shapes (lines for example) can't contain text. Those that can contain text have a TextFrame. If a Shape.TextFrame contains text, then you can use Shape.TextFrame.TextRange to get access to (set/read) the properties of all of the text in the TextFrame. Other methods also return a .TextRange that may be some subset of the text within the .TextFrame.

Simple example:

Sub DoSomethingUseless()

Dim oSh as Shape
Dim oSl as Slide

For Each oSl in ActivePresentation.Slides

For Each oSh in oSl.Shapes
   If oSh.HasTextFrame Then
      If oSh.TextFrame.HasText Then
         Debug.Print oSh.TextFrame.TextRange.Text
      End If
   End If
Next   ' Shape

Next   ' Slide

End Sub