![]() |
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 |
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 |
All times are GMT +1. The time now is 02:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com