Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
HOWTO: Use MFC to Copy a DAO Recordset to Excel with Automation
Article ID: 243394 - View products that this article applies to.
This article was previously published under Q243394
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 25, 2007 - Revision: 4.5