Article ID: 243394 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
Microsoft Excel exposes the CopyFromRecordset method for a Range object to copy the contents of a Data Access Objects (DAO) Recordset onto a worksheet. This article demonstrates how you can use MFC DAO to build a recordset that you can then copy to an Excel worksheet using automation.
The following steps demonstrate how you can obtain a recordset of all the records in the "Products" table in the sample Access database Northwind.mdb and then automate Excel to copy the contents of that recordset onto a worksheet. Although this example uses an Access database for its recordset, you could use any database for which you can provide an ODBC connection string. For details on using ODBC data sources with DAO, refer to the MFC DAO online help.
Article ID: 243394 - Last Review: January 11, 2015 - Revision: 5.0