Вот код, где ошибка:
- Код: Выделить всё
Private Sub Command1_Click()
Dim EXL As Object
Dim STR As String
Set EXL = CreateObject("Excel.Sheet")
Set EXL = EXL.Application.ActiveWorkbook.ActiveSheet
Set EXL = EXL.Evaluate(STR)
EXL.Range("C2").Value = 1
EXL.Range("C3").Value = 2
EXL.Range("C4").Value = 3
EXL.Range("C5").Value = 4
EXL.Range("C6").Value = 5
EXL.Range("B2").Value = 6
EXL.Range("B3").Value = 7
EXL.Range("B4").Value = 8
EXL.Range("B5").Value = 9
EXL.Range("B6").Value = 10
'Макрос графика
EXL.Range("B2:C6").Select
EXL.Charts.Add
EXL.ActiveChart.ChartType = xlXYScatterSmooth
EXL.ActiveChart.SetSourceData Source:=Sheets("Лист1").Range("B2:C6"), PlotBy:=xlColumns
EXL.ActiveChart.Location Where:=xlLocationAsObject, Name:="Лист1"
With EXL.ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
'Конец макроса
On Error Resume Next
EXL.SaveAs "C:\Proba.xls"
Set EXL = Nothing
End Sub