How to Retrieve a Table from Access into Excel Using DAO (146406)
The information in this article applies to:
- Microsoft Excel 97 for Windows
- Microsoft Excel for Windows 95
This article was previously published under Q146406 SUMMARY
In the versions of Microsoft Excel listed above, you can use Data Access
Objects (DAO) in Visual Basic for Applications to retrieve a table from
Microsoft Access.
To provide an example of how you can use DAO to retrieve a table from
Microsoft Access, the macro described in this article uses the Northwind
database that shipped with both Microsoft Office Professional for Windows
95, version 7.0, and Microsoft Office 97 Professional for Windows. If you
selected the default options when you installed Microsoft Office
Professional for Windows 95, version 7.0, the database is located in:
\MSOffice\Access\Samples\Northwind.mdb
If you selected the default options when you installed Microsoft Office
97 Professional for Windows, the database is located in:
\Program Files\Microsoft Office\Office\Samples\Northwind.mdb
If the Northwind database is located in a different folder on your
computer, you will need to edit the code provided below before you run
it.
To use DAO in your macro, you must reference the Microsoft DAO Object
Library or you may receive the error "User-defined type not defined". To
reference this library in Microsoft Excel version 7.0, activate a module
sheet, click References on the Tools menu, and check the "Microsoft DAO
3.0 Object Library" option. To reference this library in Microsoft Excel
version 97, click References on the Tools menu in the Visual Basic Editor
and check the "Microsoft DAO 3.5 Object Library".
REFERENCES
For more information about Data Access, click the Index tab in Microsoft
Excel Help, type the following text
and then double-click the selected text to go to the "Accessing External
Databases with DAO" topic.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbdtacode kbhowto kbinterop kbProgramming KB146406 |
---|
|