T
Tomasz Klim
Hi
I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.
Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).
oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Add
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz").Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")
For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next
.Location Where:=xlLocationAsNewSheet
'.Location Where:=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Refresh
End With
I try to create a simple line-chart from external program in Visual Basic
6.0. I already generate a quite complex Excel sheet without problems, but
when I try to add chart into this sheet, I don't see anything.
Can you check my code in case of errors? In general, when I created this
code, I followed Macro Recorder and existing code (dynamic series updating
on existing chart).
oExcel.GetWorkbook.Sheets("Main_Wykres").Charts.Add
With oExcel.GetExcel.ActiveChart
.ChartType = xlLine
.SetSourceData
Source:=oExcel.GetWorkbook.Sheets("Main_Macierz").Range("B2:AK16"),
PlotBy:=xlRows
.SeriesCollection(1).Name = Cells(2, 1)
.SeriesCollection(1).XValues = Range("B1:AK1")
For intSeria = 2 To 16
.SeriesCollection.NewSeries.Name = Cells(intSeria, 1)
.SeriesCollection.NewSeries.XValues = Range("B1", "AK1")
.SeriesCollection.NewSeries.Values = Range("B" & intSeria &
":AK" & intSeria)
Next
.Location Where:=xlLocationAsNewSheet
'.Location Where:=xlLocationAsObject, Name:="Main_Wykres"
.HasTitle = True
.ChartTitle.Text = "Multi Trend"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Refresh
End With