怎么利用vba去掉excel图表的边框和网格线?

求大神帮忙看一下下面的vba代码,如何输入语句删除图表外边框和网格线。
Sub 批量生成图表()
'部门数量
For r = 3 To 9 Step 1
ActiveSheet.Shapes.AddChart2(286, xl3DBarClustered, 500, 100, 415, 215).Select
ActiveChart.SetSourceData Source:=Sheets("sheet1").Range("c" & r & ":f" & r)
ActiveChart.SeriesCollection.NewSeries
'本类平均分
ActiveChart.FullSeriesCollection(2).Name = "=sheet1!$C$37"
ActiveChart.FullSeriesCollection(2).Values = "=sheet1!$D$37:$F$37"
ActiveChart.SeriesCollection.NewSeries
'全市平均分
ActiveChart.FullSeriesCollection(3).Name = "=sheet1!$C$41"
ActiveChart.FullSeriesCollection(3).Values = "=sheet1!$D$41:$F$41"
ActiveChart.FullSeriesCollection(3).XValues = "=sheet1!$D$1:$F$2"
ActiveChart.SetElement (msoElementLegendBottom)
ActiveChart.ApplyDataLabels
ActiveChart.FullSeriesCollection(1).DataLabels.Select
Application.CommandBars("Format Object").Visible = False
ActiveChart.SetElement (msoElementChartTitleNone)
ActiveChart.Location Where:=xlLocationAsObject, Name:="sheet1"
Set myChart = Sheet1.ChartObjects(r - 2).Chart
'使用第三列值命名图像,请勿重复
myFileName = Sheet1.Cells(r, 1) & ".bmp"
On Error Resume Next
'.删除原有同名文件
Kill ThisWorkbook.Path & "\imgfile\" & myFileName
'.将图表转换为图像并输出到指定目录,使之与H列的值相对应
myChart.Export Filename:=ThisWorkbook.Path & "\imgfile\" & myFileName, filtername:="bmp"
Set myChart = Nothing
Next

End Sub

'假设图表是选定状态你可以在相应代码后增加代码如下
ActiveChart.ShapeRange.Line.Visible = msoFalse
温馨提示:答案为网友推荐,仅供参考
相似回答