Guys,
I am having problem differentiating between Chart object and ChartObject object. Please looking into the code shown below and oblige me with explanation.
I thought the command "ActiveSheet.ChartObjects(ActiveSheet.ChartObjects.Count).Activate" would return a ChartObject object. That doesn't seem to be the case. My questions are:-Sub Macro1() ActiveWorkbook.Worksheets("Raw Data").Activate With ActiveSheet.Shapes.AddChart.Select With ActiveChart .ChartType = xlXYScatterSmoothNoMarkers .HasAxis(xlValue, xlPrimary) = True .HasAxis(xlCategory, xlPrimary) = True .SeriesCollection.NewSeries .SeriesCollection(ActiveChart.SeriesCollection.Count).Name = "=""Whatever""" .SeriesCollection(ActiveChart.SeriesCollection.Count).XValues = "='Sheet1'!$D$2:$D$133" 'x-axis .SeriesCollection(ActiveChart.SeriesCollection.Count).Values = "='Sheet1'!$E$2:$E$133" 'y-axis ActiveChart.SeriesCollection(ActiveChart.SeriesCollection.Count).Select With Selection.Format.Line .Style = msoLineSingle .Weight = 4 .Visible = msoTrue .Transparency = 0 .ForeColor.RGB = RGB(255, 0, 0) .DashStyle = msoLineSolid End With ActiveSheet.ChartObjects(ActiveSheet.ChartObjects.Count).Activate With ActiveChart .Width = 300 'The following four lines give error message that says "Method or Data Member Not Found" .Left = 300 .Height = 300 .RoundedCorners = True .HasTitle = True .ChartTitle.Text = "Blah blah blah" .ChartTitle.Select With Selection .Orientation = xlHorizontal .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom End With End with End Sub
1. Does the ChartObjects collection contain objects that are not necessarily ChartObject objects?
2. When does a Chart object become a ChartObject object?
Thanks.





Reply With Quote