Accessing labels and text boxes on slides from a VB app

S

Simon

Can someone help me?
I am trying to change the text on the label or a textbox
that I placed on a Power Point slide from another .Net VB
application.
I can start the presentation from this VB app but when I
am trying to change the text of the label, by using
Presentation.Slides(I).Shapes(J).TextFrame.TextRange.Text
= "New Text", I am getting an error "This type of shape
does not have a TextRange"
The I and J indexes are correct. They are pointing on the
Label that I want to change.

What I am doing wrong. How to change the text on the label?
It looks like standard COM approach does not work.
Thanks.
 
B

Bill Foley

Here is a line of code I use on Slide 3 to change the text of Name1 to
string StrName1:

ActivePresentation.Slides(3).Shapes("Name1").TextFrame.TextRange.Text =
strName1

Looks like all you need is "ActivePresentation" instead of "Presentation"
and quotes around the shape name.
 
S

Shyam Pillai

Simon,
The error message suggests that you are trying to manipulate a shape which
does not possess a textrange. What is the label shape you are refering to?

Regards
Shyam
 
S

Steve Rindsberg

Can someone help me?
I am trying to change the text on the label or a textbox
that I placed on a Power Point slide from another .Net VB
application.
I can start the presentation from this VB app but when I
am trying to change the text of the label, by using
Presentation.Slides(I).Shapes(J).TextFrame.TextRange.Text
= "New Text", I am getting an error "This type of shape
does not have a TextRange"
The I and J indexes are correct. They are pointing on the
Label that I want to change.

Shapes added via the controls toolbox are oddball critters.
They don't have the same properties as regular PPT shapes.
Instead, try:

Presentation.Slides(I).Shapes(J).OLEFormat.Object.Caption = "Bingo!"

(Use ... Object.Text for text boxes inserted via the controls toolbox)
 

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