Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 标记器轮廓线与系列线的线宽_Vba_Excel - Fatal编程技术网

Vba 标记器轮廓线与系列线的线宽

Vba 标记器轮廓线与系列线的线宽,vba,excel,Vba,Excel,对于折线图,在Excel UI中: 您可以在“格式化数据系列”行样式中手动更改系列行的线宽 您可以在“格式数据系列”标记线样式中手动更改标记轮廓的线宽 在VBA对象模型中,我无法区分这两个。例如,如果在录制时按顺序更改每一项,则代码如下所示: With Selection.Format.Line ' This block is from Line Style .Visible = msoTrue .Weight = 1.5 End With With Selection.Fo

对于折线图,在Excel UI中:

  • 您可以在“格式化数据系列”行样式中手动更改系列行的线宽

  • 您可以在“格式数据系列”标记线样式中手动更改标记轮廓的线宽

在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点)。但是如果我像上面那样使用代码,改变一个也会改变另一个


谢谢

这里有一个可能的解决方案:

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
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个可能的权重。 如果需要隐藏序列行(保持标记行可见),只需在“结束于”之前添加下一个代码:


此代码仅适用于第一点。将s点(1)更改为s点(3),将更改点3周围的线,以及从点2到点3的线。显然,“点”是点本身,以及将其连接到上一点的线段。因为第一个点没有上一个点,所以这段代码只在第一个点上“起作用”。@Knom:很有趣。我不知道,只测试了第一点。感谢您让我知道。让我重申一下期望的最终结果:我希望点之间的所有线段变粗,点周围的所有直线变细。(这可以通过UI实现,但我还没有找到一种用代码实现的方法)。谢谢
   .Border.LineStyle = xlNone