Line Weight of Marker Outline versus Series Line

Viewed 2305

For a line chart, in the Excel UI:

  • You can manually change the line weight of the series line in 'Format Data Series', Line Style.

  • You can manually change the line weight of the marker outline in 'Format Data Series', Marker Line Style.

I haven't been able to distinguish these two in the VBA object model. For example, if you change each one in sequence while recording, the code is as follows:

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

I want to write VBA code that will make the line between points thicker (like, 2 points), and the line around the point itself thinner (like 1 point). But if I use the code like above, changing one will change the other as well.

Thanks!

2 Answers

Here you have a possible solution:

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

This way you can set any weight to the markers-line, but you have only 4 possible weights for the series-line. And if you ever need to hide the series line (keeping the markers-line visible), just add the next code before "End with":

   .Border.LineStyle = xlNone 
Related