L
Lin Light
can you export data into a pre-existing excel spread
sheet? If column headers/names match data base field
names?
LIn
sheet? If column headers/names match data base field
names?
LIn
= .Application.Transpose(varACs)-----Original Message-----
I use an Excel template and code to to push data into it.
It involves getting the recordset and determining how large it is,
then opening a new Workbook based on the template using automation
then taking blocks of data (size depends on the number and size of columns
you want to export)
eg. this is the code snippet that actually pushes the data into the
Worksheet object
Set xlAp = New Excel.Application
Set xlWkBk = xlAp.Workbooks.Add(stFile)
Set xlWkSt = xlWkBk.Worksheets ("NextYrBudget") 'Open Budget
With xlAp
xlWkBk.Windows(1).Visible = True
.WindowState = xlMaximized
.Visible = True
End With
Dim xlRng As Excel.Range, varACs As Variant
Dim intYlst As Integer, intY As Integer, intX As Integer
With rs
.MoveFirst
intYlst = 6
Do While Not .EOF
'Copy rs into Array
varACs = .GetRows(intRows)
'Get Array boundaries
intX = UBound(varACs, 1)
intY = UBound(varACs, 2)
'Set Range for DataSet
With xlWkSht
.Activate 'Set selected Worksheet (xlWkSht as Active WkSht
Set xlRng = .Range(.Cells(intYlst, 1), _
.Cells(intYlst + intY, intX + 1))
'Paste Array into XLWkSht
xlRng.FormulaArray
Doug Bell said:I use an Excel template and code to to push data into it.
It involves getting the recordset and determining how large it is,
then opening a new Workbook based on the template using automation
then taking blocks of data (size depends on the number and size of columns
you want to export)