How to populate Excel Range from Access RecordSet?
I can't test the 64 char limit as mine are less than that, but why not
save
it to the root and then move it with VBA. If you are using the 'Range'
property in TransferSpreadsheet and using a version of Excel after 5 it
will
add a new worksheet to the workbook specified and the name in the Range
property will be the name of the worksheet.
Does that help at all.
If not we may need to look at ODBC or ADODB or similar. Equally, if the
end
product is Excel we could easily bring it in through VBA in Excel also.
(Pull rather than push)
Thanks for the reply. Saving to root and then moving the file might well be
a solution. But I've went ahead and used a Recordset for now. It's kind of
slow. I'll bet TransferSpreadsheet is quicker. In any case, the task at
hand is to get the charts looking better. If you care to offer any comments
on this chart code, that would be great.
'===== populate worksheet with data ====='
Set rst = db.OpenRecordset("ExcelData")
Do While Not rst.EOF
For m = 0 To rst.Fields.Count - 1
varCurrentField = rst(m)
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Cells(n, m + 1).Value
= varCurrentField
Next m
rst.MoveNext
n = n + 1
Loop
'===== add chart ====='
xlapp.Workbooks(strXlsFile).Charts.Add.Name = strSheetName & " Chart"
xlapp.Workbooks(strXlsFile).ActiveChart.ChartType = xlLineMarkers
'*** I think this next line needs help ***
xlapp.Workbooks(strXlsFile).ActiveChart.SetSourceD ata Source:= _
xlapp.Workbooks(strXlsFile).Worksheets(j + 1).Cells(1, 3),
PlotBy:=xlColumns
xlapp.Workbooks(strXlsFile).ActiveChart.HasLegend = False
xlapp.Workbooks(strXlsFile).ActiveChart.ApplyDataL abels
Type:=xlDataLabelsShowValue
(All this code is contained within a loop - approx 40 worksheets and charts
need to be generated)
|