ErrorBars在Excel 2007中格式化

在Excel 2007中使用macros我想要显示以下错误栏:

  • 没有水平的错误栏。
  • 红色与100加值垂直错误栏虚线。

我可以得到我想要的一切,除了颜色,我不明白为什么。 贝娄是代码。

ActiveChart.SeriesCollection(6).HasErrorBars = True With ActiveChart.SeriesCollection(6).ErrorBars .EndStyle = xlNoCap .Format.Line.Visible = msoTrue .Format.Line.ForeColor.RGB = RGB(255, 0, 0) .Format.Line.ForeColor.TintAndShade = 0 .Format.Line.Weight = 2 .Format.Line.DashStyle = msoLineDash End With ActiveChart.SeriesCollection(6).ErrorBar Direction:=xlX, Include:=xlNone, Type:=xlFixedValue, Amount:=0 ActiveChart.SeriesCollection(6).ErrorBar Direction:=xlY, Include:=xlPlusValues, Type:=xlFixedValue, Amount:=100 

我也遇到了同样的问题。 但是在切换错误栏的可见状态后,颜色变化对我有用。 试试这个:

 ActiveChart.SeriesCollection(6).HasErrorBars = True With ActiveChart.SeriesCollection(6).ErrorBars .EndStyle = xlNoCap .Format.Line.Visible = msoTrue .Format.Line.ForeColor.RGB = RGB(255, 0, 0) .Format.Line.Visible = False 'ADDED .Format.Line.Visible = True 'ADDED .Format.Line.ForeColor.RGB = RGB(255, 0, 0) 'ADDED .Format.Line.ForeColor.TintAndShade = 0 .Format.Line.Weight = 2 .Format.Line.DashStyle = msoLineDash End With