jDa*_*984 6 excel charts vba excel-vba
我试图通过Excel VBA在图表中创建ErrorBars,但我需要宽度为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
Run Code Online (Sandbox Code Playgroud)
我认为使用Weight属性会起作用,但是我忽略了什么吗?
小智 -2
根据 Microsoft 文档,您需要使用 'weight' :
错误栏 --> 边框: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