VBA运行时间错误“7”当命名xlXY ScatterLines图表 [英] VBA run-time error "7" when naming xlXY ScatterLines chart

查看:808
本文介绍了VBA运行时间错误“7”当命名xlXY ScatterLines图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的代码需要我命名一个图表,所以我以后可以参考它。我使用的代码是:

I'm running a code that requires me to name a chart so I can refer back to it later. The code I use for this is:

Sheets("Summary").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlXYScatterLines
With ActiveChart
    .Name = "energy distribution chart"
End With

我试过命名图表不使用with ...如:

I've tried just naming the chart not using the with... as in:

ActiveChart.Name = "energy distribution chart"

每当代码运行在那行我得到一个运行时错误7 - 内存不足。我试着把这个代码,使它开始运行在一个新的宏在一个新的模块,但它仍然总是得到这个错误7 - 3行代码到一个新的代码!我不知道发生了什么事。帮助?

Doesn't work also. Whenever the code runs at that line I get a "run-time error 7 - Out of memory". I've tried putting this code so that it starts to run in a new macro in a new module but it still always gets that error 7 - 3 lines into a new piece of code! I have no idea what's going on. Help?

编辑:按照mehow的答案,如何重新选择图表?

Following to mehow's answer, how do I then re-select the chart?

've tried:

I've tried:

With Worksheets("Summary").ChartObjects("energy distribution chart").Chart(1)
    .SeriesCollection(sheet_number - 1).XValues = Worksheets(sheet_number).Range(Sheets(sheet_number).Cells(1, 7), Sheets(sheet_number).Cells(i4, 7))
    .SeriesCollection(sheet_number - 1).Values = Worksheets(sheet_number).Range(Sheets(sheet_number).Cells(1, 8), Sheets(sheet_number).Cells(i4, 8))
End With

这似乎不工作... .. hm。我也试图摆脱(1)旁边的图表。是的。不知道。

Which doesn't seem to work... .. hm. I've also tried getting rid of the (1) next to charts. Yep. No idea.

推荐答案

图表是一个嵌入对象。如果您要更改对象(不是图表本身),则

Chart it's an embed object. If you want to change of the object ( not chart itself ) then

ActiveChart.Parent.Name = "chart name"

请参阅 MSDN了解详情

这篇关于VBA运行时间错误“7”当命名xlXY ScatterLines图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆