对于折线图,在Excel用户界面中:
您可以在'格式数据系列',线型中手动更改系列线的线宽。
您可以在'格式数据系列',标记线样式中手动更改标记轮廓的线宽。
我还没能在VBA对象模型中区分这两者。例如,如果您在录制时按顺序更改每个,则代码如下:
With Selection.Format.Line ' This block is from Line Style
.Visible = msoTrue
.Weight = 1.5
End With
With Selection.Format.Line ' This block is from Marker Line Style
.Visible = msoTrue
.Weight = 2
End With
我想编写VBA代码,使点之间的线条更粗(如2点),并且点周围的线本身更薄(如1点)。但是如果我使用上面的代码,那么改变另一个代码也会改变另一个代码。
谢谢!
答案 0 :(得分:0)
这里有一个可能的解决方案:
ActiveChart.SeriesCollection(1).Select
With Selection
.Format.Line.Weight = 2 'Sets thickness = 2 to markers-line and series-line
.Border.Weight = xlHairLine 'Sets thickness = 0.25 to the series-line
.Border.Weight = xlThin 'Sets thickness = 1 to the series-line
.Border.Weight = xlMedium 'Sets thickness = 2 to the series-line
.Border.Weight = xlThick 'Sets thickness = 3 to the series-line
End With
通过这种方式,您可以为标记线设置任何权重,但对于系列线您只有 4 个可能的权重。 如果您需要隐藏系列线(保持标记线可见),只需在“结束于”之前添加下一个代码:
.Border.LineStyle = xlNone
答案 1 :(得分:-2)
Dim co As ChartObject
Dim c As Chart
Dim s As Series
Dim p As Point
Set co = Sheet1.ChartObjects(1)
Set c = co.Chart
Set s = c.SeriesCollection(1)
Set p = s.Points(1)
p.Format.Line.Weight = 3