vba Excel图表没有标题错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25789077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel Chart has no title error
提问by Bramat
I'm working with VBA trying to make charts. The chart is created like it should, but when I try to define a title, I get this error: "run time error '-2147024809 (80070057): this object has no title."
我正在使用 VBA 尝试制作图表。图表的创建方式应该是这样,但是当我尝试定义标题时,出现此错误:“运行时错误 '-2147024809 (80070057):此对象没有标题。”
my VBA line is:
我的 VBA 线是:
ActiveChart.ChartTitle.Text = "From " & Cells(Start, Prev) & " To " & Cells(Start, Op) & " - Recomended Setup: 0"
Does anyone has any idea why It's not working? (the same line worked on another chart already...) Thank you!
有谁知道为什么它不起作用?(同一行已经在另一个图表上工作了......)谢谢!
回答by Siddharth Rout
That is because you need to create the title before you can set it. Add this line before your code
那是因为您需要先创建标题,然后才能对其进行设置。在您的代码之前添加此行
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "From " & Cells(Start, Prev) & _
" To " & Cells(Start, Op) & _
" - Recomended Setup: 0"