Transfer of values from an object to an XY chart
VB6 EXCEL2000
I am trying to automate plotting an XY curve from data contained in an object. Basically there appears to be no way of transfering the contents of an object into chart's x and y values (.XValues & .Values respectively). Edited code below.
Source data from array dFrequency is placed in a collection (for good reasons!). dFrequency may have up to 1600 elements, read in from a file.
Public FreqTable As New Collection
.
.
For n = 1 To nNoDataPoints
Set FreqPoint = New clsInsertFreq
FreqPoint.Freq = dFrequency(n)
FreqTable.Add FreqPoint
Next
Then the chart X&Y values is set up as follows (template already exists):
' Find the chart
Set chtObject = Worksheets("S11 dB").ChartObjects("Chart 1")
' Find the series
Set Cht = chtObject.Chart
Set scSeries = Cht.SeriesCollection
' Enter values into a new series
With scSeries.NewSeries
.Name = "Input Return Loss"
.Values =
.XValues = ???
End With
??? = all the .Freq values in FreqPoint into the XValues (never mind Y values for now) so that a graph can be generated, eg .XValues = FreqPoint.Item(n).Freq for n = 1 to nNoDataPoints would be nice.
As .XValues need variant arrays or cells there is clearly a type mismatch issue.
On one hand it looks as if I am doing something illegal, on the other surely the point of a chart to accept data...
Thanks.
|