Excel VBA图表轴错误:对象“Axis”失败的“Method”ScaleType“当读取`.ScaleType`时 [英] Excel VBA chart axis error: "Method 'ScaleType' of object 'Axis' failed" when reading `.ScaleType`
问题描述
我在Excel VBA宏中有一个作业
I have an assignment in an Excel VBA macro
axscty = ax.ScaleType
其中给出了错误:方法'ScaleType'对象'轴'失败。
我发现源代码说它是Excel 2007中的一个错误。其他人发现设置 .ScaleType
时出错,例如
which gives the error: "Method 'ScaleType' of object 'Axis' failed".
I found sources stating that it is a bug in Excel 2007. Others found the error when setting .ScaleType
, e.g.,
.ScaleType = xlLinear
我有发现错误的原因:我有一个辅助Y轴与数据系列。如果我将这些系列分配给主Y轴并删除辅助轴,则错误消失。
I have found the cause of the error: I have a secondary Y-axis with data series. If I assign those series to the primary Y-axis and remove the secondary axis, the error disappears.
任何人都知道如果有一个辅助Y轴,轴?
Anyone knows how to avoid the error when there is a secondary Y-axis?
推荐答案
它看起来像下面的工作(如果你有任何辅助轴):
It looks like the following works (if you have any secondary axis or not):
ActiveChart.SetElement (msoElementPrimaryCategoryAxisLogScale)
ActiveChart.SetElement (msoElementPrimaryValueAxisLogScale)
ActiveChart.SetElement (msoElementSecondaryCategoryAxisLogScale)
ActiveChart.SetElement (msoElementSecondaryValueAxisLogScale)
这篇关于Excel VBA图表轴错误:对象“Axis”失败的“Method”ScaleType“当读取`.ScaleType`时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!