Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Sub Run-time error

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
Receiving run-time error only part of the time [email protected] Excel Discussion (Misc queries) 0 August 11th 07 12:01 AM
run-time error '91'-Close Button error ASCO IS Help Excel Discussion (Misc queries) 1 May 8th 06 04:25 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM


All times are GMT +1. The time now is 04:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"