Reputation: 64
I want to manipulate an existing chart to filter data series and change title by clicking command buttons on a worksheet, but I'm getting runtime error 438 when trying to write code for some operations.
First, a line
Worksheets("Report").ChartObjects("ChartVisitors").Visible=True
(or False)
works just fine, but when I try:
Worksheets("Report").ChartObjects("ChartVisitors").ChartTitle.Text = "Test"
or
Worksheets("Report").ChartObjects("ChartVisitors").FullSeriesCollection(25).IsFiltered = True (False)
, I get runtime error 438. Those two are pretty much the only properties I want to modify, I'm guessing my syntax is wrong? MSDN only specifies that the chart should have .HasTitle
property set to True, which it does.
Upvotes: 2
Views: 1615
Reputation: 51988
A ChartObject
functions as a container for a Chart
object. Think of it as the window that the chart is embedded in. You need:
Worksheets("Report").ChartObjects("ChartVisitors").Chart.ChartTitle.Text = "Test"
Rather than
Worksheets("Report").ChartObjects("ChartVisitors").ChartTitle.Text = "Test"
etc.
Upvotes: 5