After much great advice and tips from various members, I thought I might share with you how I solved this problem.
The below block needs for you to reference Excel.
-- start block
Dim AppExcel As New Excel.Application
Dim xlDoc As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim objChart As ChartObject
Dim xlSeries As SeriesCollection
Dim strName() As String
Dim strXAxis As String
Dim strSQL As String
Dim intHeight As Integer
strSQL = "Select * From DB_Table "
Set xlDoc = AppExcel.Workbooks.Add
Set xlSheet = xlDoc.Worksheets(1)
Set m_rsData = New ADODB.Recordset
With m_rsData
.Open strSQL, OraDb
redim strName(.Fields.Count) as String
'This Gives Titles in a down fashion.
'To go across, one must go B1,C1,D1 for which I do not have a loop
for iLoop=1 to .Fields.Count-1
xlSheet.Range("B" & .Fields(iLoop).Name & ).Cells=.Fields(iLoop).Name
next iLoop
'start the series collection
Set xlSeries = objChart.Chart.SeriesCollection
For iCount = 1 To 2 'the number of named ranges (which should be the number of fields)
xlSeries.Add "Range" & iCount
xlSeries.Item(iCount).Name = strName(iCount)
Next iCount
Set m_rsData = Nothing
exit sub
-- end block
you may also use the chartwizard after adding a chart
object
objChart.Chart.Chartwizard Arguments
where Arguments is
1.Source: Optional Variant. The range that contains the source data for the new chart. If this argument is omitted, Microsoft Excel edits the active chart sheet or the selected chart on the active worksheet.
2.Gallery: Optional Variant. The chart type. Can be one of the following XlChartType constants: xlArea, xlBar, xlColumn, xlLine, xlPie, xlRadar, xlXYScatter, xlCombination, xl3DArea, xl3DBar, xl3DColumn, xl3DLine, xl3DPie, xl3DSurface, xlDoughnut, or xlDefaultAutoFormat.
Format: Optional Variant. The option number for the built-in autoformats. Can be a number from 1 through 10, depending on the gallery type. If this argument is omitted, Microsoft Excel chooses a default value based on the gallery type and data source.
3.PlotBy: Optional Variant. Specifies whether the data for each series is in rows or columns. Can be one of the following XlRowCol constants: xlRows or xlColumns.
CategoryLabels: Optional Variant. An integer specifying the number of rows or columns within the source range that contain category labels. Legal values are from 0 (zero) through one less than the maximum number of the corresponding categories or series.
4.SeriesLabels: Optional Variant. An integer specifying the number of rows or columns within the source range that contain series labels. Legal values are from 0 (zero) through one less than the maximum number of the corresponding categories or series.
5.HasLegend: Optional Variant. True to include a legend.
6.Title: Optional Variant. The chart title text.
7.CategoryTitle: Optional Variant. The category axis title text.
8.ValueTitle: Optional Variant. The value axis title text.
9.ExtraTitle: Optional Variant. The series axis title for 3-D charts or the second value axis title for 2-D charts.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.