Visual Basic 6中的Excel – 如何用平滑线创build图表?

在Excel 2016中,在(右键单击图表上的行)>格式化数据系列>平滑线(平滑线)时,会出现一个选项。 通过Visual Basic 6创buildExcel图表时,是否有任何方法来启用此选项?

此链接文档在Visual Basic for Applications中的选项,但我没有find任何用于Visual Basic 6: https : //msdn.microsoft.com/en-us/library/office/ff195315(v=office.14).aspx

这里是我在Visual Basic 6中创build图表的代码:

Dim xlApp As excel.Application Set xlApp = New excel.Application Dim xlWkb As excel.Workbook Set xlWkb = xlApp.Workbooks.Open("D:\Documents\Book1.xlsx") Dim xlSht As excel.Worksheet Set xlSht = xlWkb.Worksheets(1) Dim xlChart As excel.Chart Set xlChart = xlWkb.Charts.Add xlChart.ChartType = xlLine xlChart.SetSourceData xlSht.Range("A1:B5"), xlColumns xlChart.Visible = xlSheetVisible xlChart.Legend.Clear xlChart.ChartArea.Font.Size = 15 xlChart.ChartArea.Font.Color = vbRed xlChart.ChartArea.Select xlChart.ChartArea.Copy Image1.Picture = Clipboard.GetData(vbCFBitmap) ' Image1 is an image control already placed on the Form. 

这是图表中每个系列公开的属性( .Smooth ),因此您需要循环它们并分配,例如

 Dim xlChart As Excel.Chart Set xlChart = xlWkb.Charts.Add With xlChart .ChartType = xlLine .SetSourceData xlSht.Range("A1:B5"), xlColumns .Visible = xlSheetVisible .Legend.Clear .ChartArea.Font.Size = 15 .ChartArea.Font.Color = vbRed Dim i As Long For i = 1 To .FullSeriesCollection.Count .FullSeriesCollection(i).Smooth = True '// <= Next .ChartArea.Select .ChartArea.Copy End With