none
Change Excel chart line style with vba RRS feed

  • Question

  • Hello,

    I would like to change the "Cap type" of a serie line style on a chart with vba on Excel 2007, but I don't find how.

    Tuesday, November 15, 2011 8:36 AM

Answers

  • Not sure what you mean by "Cap type" with respect to a series line style, however try this

    Dim cht As Chart, sr As Series
    Set cht = ActiveChart
    Set sr = cht.SeriesCollection(1)
    
    ' 2007 and later only
    Dim msoLS As Office.MsoLineStyle
    Dim msoDS As MsoLineDashStyle
    
    msoLS = msoLineThickBetweenThin
    sr.Format.Line.Style = msoLS
    
    msoDS = msoLineLongDashDot
    sr.Format.Line.DashStyle = msoDS
     ' all versions
    Dim xlLS As XlLineStyle
    xlLS = xlDashDotDot
    sr.Border.LineStyle = xlLS

    You might also want LineWeight

    You should get the intellisense after the various = signs

    Peter Thornton

    Tuesday, November 15, 2011 11:31 AM
    Moderator

All replies

  • Not sure what you mean by "Cap type" with respect to a series line style, however try this

    Dim cht As Chart, sr As Series
    Set cht = ActiveChart
    Set sr = cht.SeriesCollection(1)
    
    ' 2007 and later only
    Dim msoLS As Office.MsoLineStyle
    Dim msoDS As MsoLineDashStyle
    
    msoLS = msoLineThickBetweenThin
    sr.Format.Line.Style = msoLS
    
    msoDS = msoLineLongDashDot
    sr.Format.Line.DashStyle = msoDS
     ' all versions
    Dim xlLS As XlLineStyle
    xlLS = xlDashDotDot
    sr.Border.LineStyle = xlLS

    You might also want LineWeight

    You should get the intellisense after the various = signs

    Peter Thornton

    Tuesday, November 15, 2011 11:31 AM
    Moderator
  • https://support.microsoft.com/en-us/help/2755172/you-cannot-use-vba-code-to-configure-the-cap-type-and-join-type-properties-in-excel
    Sunday, April 2, 2017 12:31 PM