PowerPoint: Change the text in a text type shape via automation

D

Dale Fye

Office 2003

What is the appropriate property of a textbox type shape to change the text
that appears in the shape, programmatically?

I'm creating a customized charting function, and want to create a legend on
the fly, but need to know how to change the text inside the textbox.

Dale
 
S

Steve Rindsberg

Dale Fye said:
Office 2003

What is the appropriate property of a textbox type shape to change the text
that appears in the shape, programmatically?

I'm creating a customized charting function, and want to create a legend on
the fly, but need to know how to change the text inside the textbox.

Assuming you have a reference to the shape in the variable oSh:

With oSh.TextFrame.TextRange
.Text = "At your service, Master"
End With

If you're working with any old shape, it's good practice to surround all this
with tests to make sure the shape has a text frame ( if oSh.HasTextFrame ) and
the text frame has text ( if oSh.TextFrame.HasText ) because some shapes
cannot have textframes.

In your case, since you can limit yourself to creating shapes that are known to
work, I don't see any need for the belt, braces, rope and hand on beltbuckle.
 
D

Dale Fye

Thanks, Steve.
Got it working great.

Steve Rindsberg said:
Assuming you have a reference to the shape in the variable oSh:

With oSh.TextFrame.TextRange
.Text = "At your service, Master"
End With

If you're working with any old shape, it's good practice to surround all
this
with tests to make sure the shape has a text frame ( if oSh.HasTextFrame )
and
the text frame has text ( if oSh.TextFrame.HasText ) because some shapes
cannot have textframes.

In your case, since you can limit yourself to creating shapes that are
known to
work, I don't see any need for the belt, braces, rope and hand on
beltbuckle.

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top