Char syntax problem RRS feed

  • Question

  • Hi,

    I have created a chart using the syntax below.

    Set chtSupplyAndDemand = AnalysisSummSh.Shapes.AddChart2( _
                            Style:=297, _
                            XlChartType:=xlColumnStacked, _
                            Top:=310, _
                            Left:=10, _
                            Height:=AnalysisSummSh.Range("A15:A29").Height, _
                            Width:=550, _

    followed by

    With chtSupplyAndDemand

           .SetSourceData Source:=[GRAPH_SupplyAndDemand] ' Named range
           .ChartTitle.text = " SUPPLY AND DEMAND"
           .ChartTitle.Format.TextFrame2.TextRange.Font.Size = 12
           .ChartTitle.Format.TextFrame2.TextRange.Font.Bold = msoTrue
           .Axes(xlValue).MajorUnit = gintSupDemMajorUnit
           .Axes(xlCategory).TickLabels.Orientation = xlUpward
           .SetElement (msoElementLegendNone)
           .SetElement (msoElementPrimaryValueGridLinesNone)

    there is more code below which i have omitted. All this works fine.

    I am trying to figure out how to remove the border around the whole chart. When i record a macro to do this it gives me:

    ActiveSheet.ChartObjects("Chart 23").Activate
    ActiveSheet.Shapes("Chart 23").Line.visible = msoFalse

    The difficulty I am having is that it seems that i need to sepcify the index (Chart 23 in this example) - but I am not sure how i would do this in the code above.

    I hope this makes sense - what I want to do is simply have no line around the chart.

    Help please?

    thank you.


    Friday, November 10, 2017 2:06 PM


  • You can use

            .ChartArea.Format.Line.Visible = msoFalse

    inside the With chtSupplyAndDemand ... End With block

    Regards, Hans Vogelaar (

    Friday, November 10, 2017 5:15 PM

All replies