Unable to change the width of custom error fields

I am trying to create ErrorBars in a chart through Excel VBA, but I need 12PT width or vary. Here is the code I use, but it does not look like this:

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 

I figured that using the Weight property would work, but am I missing something?

+6
source share
2 answers

I think the problem is .HasErrorBars = True , which automatically creates an error panel automatically if it is not, and the next line .ErrorBar creates another.

At this moment you have two lines of errors, and .Format.Line.Weight = 12 in my case affects only the first automatically added.

Try setting .HasErrorBars = False before using .ErrorBar , and see if it matters.

 .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 

* Another thing to try is to switch .Format.Line.Visible after changes to update.

+2
source

According to Microsoft documentation, you should use "weight":

ErrorBars β†’ Border: https://msdn.microsoft.com/en-us/library/aa174210%28v=office.11%29.aspx

Border β†’ Weight: https://msdn.microsoft.com/en-us/library/aa215968%28v=office.11%29.aspx

-2
source

Source: https://habr.com/ru/post/986017/


All Articles