不能更改自定义ErrorBars的宽度

我想通过Excel VBA在图表中创buildErrorBars,但我需要宽度为12PT,或者变化。 这里是我正在使用的代码,但它看起来不像它的工作:

Set s = .SeriesCollection.NewSeries() With s .Name = "=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("Activity").Range.Column) & "$" & sourceRow .XValues = "=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("DateMid").Range.Column) & "$" & sourceRow .Values = "=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("Loc1").Range.Column) & "$" & sourceRow .HasErrorBars = True .ErrorBar Direction:=xlX, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:="=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("BarLength").Range.Column) & "$" & sourceRow, MinusValues:="=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("BarLength").Range.Column) & "$" & sourceRow Set eB = .ErrorBars With eB With .Format.Line .Visible = msoTrue .Style = msoLineSingle .Weight = 12 End With .EndStyle = xlNoCap End With .HasDataLabels = True Set dLabels = .DataLabels With dLabels .Format.TextFrame2.TextRange.InsertChartField msoChartFieldRange, "=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("Activity").Range.Column) & "$" & sourceRow .ShowRange = True .ShowSeriesName = False .ShowValue = False End With End With 

我认为使用Weight属性会起作用,但我忽略了什么?

我认为问题是.HasErrorBars = True ,如果不存在,它已经自动创build一个错误栏,而下一行.ErrorBar创build另一个。

在这一点上,你有两个错误栏,在我的情况.Format.Line.Weight = 12只影响第一个自动添加一个。

在使用.ErrorBar之前尝试设置.HasErrorBars = False ,看看它是否.HasErrorBars = False

 .HasErrorBars = False .ErrorBar Direction:=xlX, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:="=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("BarLength").Range.Column) & "$" & sourceRow, MinusValues:="=GraphicSchedule!$" & getColumn(objList.ListColumns.Item("BarLength").Range.Column) & "$" & sourceRow 

*另一个要尝试的是更改刷新后切换.Format.Line.Visible

按照Microsoft文档,您需要使用“权重”:

ErrorBars – > Border: https ://msdn.microsoft.com/en-us/library/aa174210%28v=office.11​​%29.aspx

边框 – >重量: https : //msdn.microsoft.com/en-us/library/aa215968%28v=office.11​​%29.aspx