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)
Note that until Excel2002, Application.Transpose was limited to 5461
elements. Also, your approach is long winded. If you are taking on the
overhead of automation, the CopyFromRecordset method is preferable,
which supported ADO recordsets from Excel2000, because you don't have
to e.g. find out large the recordset is etc.
However, automation is usually not needed. Preferable to use a INSERT
INTO..SELECT query e.g. to update an existing Excel table:
INSERT INTO
[Excel 8.0;database=C:\MyWorkbook.xls;].MyBookLevelName
(MyCol1, MyCol2, MyCol3)
SELECT
ColA AS MyCol1,
ColB AS MyCol2,
ColC AS MyCol3
FROM
MyTable
;
To create a new Excel workbook/worksheet/table:
SELECT
ColA AS MyCol1,
ColB AS MyCol2,
ColC AS MyCol3
INTO
[Excel 8.0;database=C:\NewWorkbook.xls;].Sheet1
FROM
MyTable
;
Jamie.
--