简体   繁体   English

对象_chart的方法名称失败

[英]Method name of object _chart failed

I am getting a Run Time error 1004 :Method name of object _chart failed while I try to name my chart. 我收到Run Time error 1004 :Method name of object _chart failed尝试命名图表时Run Time error 1004 :Method name of object _chart failed Sometimes this runs, and sometimes it doesn't. 有时会运行,有时却不会。 Here is the part that causes the error, (the whole macro is really long, so I haven't posted it all.) 这是导致错误的部分,(整个宏真的很长,因此我还没有全部发布。)

Drawing a 3D col chart of the histogram: 绘制直方图的3D col图表:

Range("U1:R23").Select
    Charts.Add
    ActiveChart.ChartType = xlCylinderCol
    ActiveChart.Name = "mcChart" -----------> Error
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Dynamic Weight Chasing Histogram" & Chr(10) & "Local SWT ,File:" & Name & ", Roadforce-Check Spin" & Chr(10) & "assembly after dimensions changed, Old software"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "weights(Oz)"
Charts("mcChart").SeriesCollection(1).XValues = Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, "4-5", "5-6", "6-7", "7-8", "8-9", "9-10")
.SeriesCollection([4]).Interior.Color = RGB(139, 0, 0) ' dark red
.SeriesCollection([3]).Interior.Color = RGB(205, 92, 92) 'indian red
.SeriesCollection([2]).Interior.Color = RGB(128, 0, 128) 'magenta
.SeriesCollection([1]).Interior.Color = RGB(144, 238, 144) 'light green
End With

Please let me know if you can find a solution to this problem. 如果您可以找到解决此问题的方法,请告诉我。

Can you modify your code and see if it works? 您可以修改代码并查看它是否有效吗?

dim newChart as Chart

Range("U1:R23").Select
Set newChart = Charts.Add

With newChart
   .ChartType = xlCylinderCol
   .Name = "mcChart" & Format(now, "hhmmss")

   'setting other properties
End With

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel VBA .AddChart方法'对象'_chart'的'SetSource数据'失败 - Excel VBA .AddChart Method 'SetSource Data' of Object' _chart' failed VBA:对于多个数据透视图,对象“_Chart”的方法“SetSourceData”失败 - VBA: Method 'SetSourceData' of object '_Chart' failed For Multiple Pivot Charts VBA图表错误对象'_Chart'的方法'Axes'对于辅助轴标题失败 - VBA chart error Method 'Axes' of Object '_Chart' failed for secondary axis title 运行时错误 32813 - 对象“_VBComponent”的方法“名称”失败 - Runtime error 32813 - Method 'Name' of object '_VBComponent' failed VBA:从1个工作表中的多个数据透视表创建多个数据透视图[错误:对象'_chart'的方法'SetSourceData'失败] - VBA: Create multiple pivot charts from multiple pivot tables in 1 sheet [Error: Method 'SetSourceData' of object '_chart' failed] Excel VBA图表轴错误:读取`.ScaleType`时,“对象'Axis'的方法'ScaleType'失败” - Excel VBA chart axis error: “Method 'ScaleType' of object 'Axis' failed” when reading `.ScaleType` VBA 错误 1004:Chart.ChartData.Workbook object 的方法“关闭”失败 - VBA Error 1004 : Method “Close” of Chart.ChartData.Workbook object Failed 方法导出对象'_Chart'失败运行时错误-2147286987 80030035 - Method Export of object '_Chart' failed Run-time error -2147286987 80030035 目录中存在相同名称的文件时,“对象_workbook的方法另存为失败” - “Method saveas of object _workbook failed” when same name file present in directory 对象_Global的方法“范围”失败 - Method “Range” of object _Global" failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM