View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Sub Run-time error

Sub ListCharts()
Dim Msg As String
Dim ChtOb As ChartObject
Msg = ActiveSheet.Name & vbCrLf
For Each ChtOb In ActiveSheet.ChartObjects
if chtOb.HasTitle then
Msg = Msg & vbCrLf & ChtOb.Name & " : " & _
ChtOb.Chart.ChartTitle.Caption
Else
Msg = Msg & vbCrLf & chtOb.Name & ":" & _
"No title"
End if
Next
MsgBox Msg
End Sub

--
Regards,
Tom Ogilvy


"Phil Hageman" wrote in message
...
The following sub is suppose to make a list of all charts
in a worksheet. When running the sub, I get Run-time
error '1004': Unable to get the Caption property of the
ChartTitle class. The line Msg = Msg & vbCrLf... is
highlighted. Can someone help me fix this.

Sub ListCharts()
Dim Msg As String
Dim ChtOb As ChartObject
Msg = ActiveSheet.Name & vbCrLf
For Each ChtOb In ActiveSheet.ChartObjects
Msg = Msg & vbCrLf & ChtOb.Name & " : " &
ChtOb.Chart.ChartTitle.Caption
Next
MsgBox Msg
End Sub