excel VBA图表格式 – 需要改变一行的宽度

我正在尝试编写格式化图表(myChart)的代码。 系列2和4是我需要格式化,所以他们的重量= 1。我已经尝试过,没有运气。

myChart.fullseriescollection(2).format.line.weigth = 1 

我对VBA相当陌生,以前从来没有尝试引用图表对象,所以我不熟悉正确的语法。

谢谢! 看到我的代码如下。

 Sub myChart() Dim myChart As Chart, cht As ChartObject Dim rngChart As Range, destSht As String Dim rngData As Range destSht = ActiveSheet.Name Set myChart = Charts.Add Set myChart = myChart.Location(where:=xlLocationAsObject, Name:=destSht) With ActiveSheet.ListObjects("Table1").DataBodyRange Set rngData = Union(.Columns(2), .Columns(9), .Columns(10), .Columns(11), .Columns(12)) End With With myChart .SetSourceData Source:=rngData, PlotBy:=xlColumns .ChartType = xlColumnClustered .ChartStyle = 209 *****Below is the first series line that I want to format***** With .FullSeriesCollection(2) .ChartType = xlLine .AxisGroup = 1 End With With .FullSeriesCollection(3) .ChartType = xlLineMarkers .AxisGroup = 2 End With *****2nd line I want to format***** With .FullSeriesCollection(4) .ChartType = xlLine .AxisGroup = 2 End With End With ActiveSheet.ChartObjects(1).Activate Set cht = ActiveChart.Parent Set rngChart = Range("A1100:K1115") cht.Left = rngChart.Left cht.Top = rngChart.Top cht.Width = rngChart.Width cht.Height = rngChart.Height Range("A2").Select End Sub 

 With .FullSeriesCollection(2) .ChartType = xlLine .AxisGroup = 1 .Format.Line.Weight = 5 End With 

在Office 2016中工作得很好。

我会评论,但我还没有足够高的声誉呢