refined question

J

Jamie Martin

I figured out how to change the text in a chart shape. However, my procedure
fails if there are any shapes on my chart that do not have any text. I tried
several ways around this, but they all gave me a runtime error. Here's an
example:

For Each Shp In Cht.Shapes
If (Shp.TextFrame.Characters.Text <> "") Then
Shp.TextFrame.Characters.Text = _
WorksheetFunction.Substitute _
(Shp.TextFrame.Characters.Text, Str1, Str2)
End If
Next Shp

I also tried "If(Shp.TextFrame Is Nothing) Then"

Can someone help? Thanks very much.

Jamie
 
T

Tom Ogilvy

On Error Resume Next
For Each Shp In Cht.Shapes
If (Shp.TextFrame.Characters.Text <> "") Then
Shp.TextFrame.Characters.Text = _
WorksheetFunction.Substitute _
(Shp.TextFrame.Characters.Text, Str1, Str2)
End If
Next Shp
On Error goto 0
 

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