我正在尝试从我放入工作表中的 5 个 ActiveX 文本框创建一个图表。首先,用户输入值,然后按下生成图表的按钮。
这是我的方法,但它不起作用。它说类似“需要对象”
Private Sub CommandButton1_Click()
Dim arKurse(4) As Double
arKurse(0) = Conver.ToDouble(TextBox1.Text)
arKurse(1) = Conver.ToDouble(TextBox2.Text)
arKurse(2) = Conver.ToDouble(TextBox3.Text)
arKurse(3) = Conver.ToDouble(TextBox4.Text)
arKurse(4) = Conver.ToDouble(TextBox5.Text)
Dim oChtObj As ChartObject
Set oChtObj = ActiveSheet.ChartObjects.Add(Left:=445, Width:=385, Top:=10, Height:=245)
With oChtObj.Chart
.SeriesCollection.NewSeries
.SeriesCollection.Values = arKurse
.SeriesCollection.XValues = Array("1", "2", "3", "4", "5")
.ChartType = xlLine
.HasLegend = False
.HasTitle = True
.ChartTitle.Caption = "Chart"
End With
End Sub