vba图表在Excel 2010中

我只是想绘制一个简单的系列图,但是当我尝试标记我的坐标轴时,出现了一些奇怪的错误。 我如何标记我的x,y轴?

With ActiveSheet.ChartObjects.Add(Left:=10, Width:=875, Top:=75, Height:=425) .Chart.SetSourceData Source:=ws.Range("A1:B" & rows) .Chart.ChartType = xlLine With ActiveChart .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Price" End With End With 

错误是:对象variables或块variables未设置

这工作对我来说,尝试删除与另一个块内:

 ActiveSheet.Shapes.AddChart(Left:=10, Width:=875, Top:=75, Height:=425).Select With ActiveChart .SetSourceData Source:=ws.Range("A1:B" & rows) .ChartType = xlLine .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Text = "Time" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Price" End With