Changing Text in PowerPoint

K

KD

Hi,

I have written some Excel vba code that is supposed to
change the value of a text box in PowerPoint. I am using
Excel 2002 and PowerPoint 2002 and the problem is that
when I try and run the code it errors out and says :

Run-time error '-2147188160 (80048240)' :
TextFrame (unknown member ): Invalid request. This type of
shape cannot have a text range.

I am trying to update text within a rectangle - so could
this be the reason my code of :

oPPTApp.ActivePresentation.Slides(slide_no).Select
With oPPTApp.ActivePresentation.Slides(slide_no)
For Each oPPTShape In .Shapes
If oPPTShape.TextFrame.TextRange.Text = find_text Then
oPPTShape.TextFrame.TextRange.Text = replace_text

......


does not work? How else could I get around the problem of
trying to update a rectangle with text within it?

Many thanks
KD
 
A

Andy Pope

Hi,

Is it possible you have objects on the slide that do not have a
textframe property, like a chart?

Maybe use some error handling or test the shape type before trying to
change the property.

Cheers
Andy
 
K

KD

Hi,

Thanks that seems to work now I've put a test in place -
also how do I change the color of my new text, I am
trying :

oPPTShape.TextFrame.TextRange.Font.Color=38

and it does not appear to be working.

Many thanks for your help

KD
 
A

Andy Pope

Hi,

I assume the text appears black.
You need to specify the color either using RGB or SchemeColor.

oPPTShape.TextFrame.TextRange.Font.Color.RGB=RGB(255,0,0) ' Red

oPPTShape.TextFrame.TextRange.Font.Color.SchemeColor = 4

Cheers
Andy
 

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