Article ID: 146406 - View products that this article applies to.
This article was previously published under Q146406
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:
If you selected the default options when you installed Microsoft Office 97 Professional for Windows, the database is located in:
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.
\Program Files\Microsoft Office\Office\Samples\Northwind.mdb
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".
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To retrieve a table from Microsoft Access, follow these steps:
To retrieve a table from Microsoft Access programmatically, use the following Visual Basic for Applications code:
For more information about Data Access, click the Index tab in Microsoft Excel Help, type the following text
data access in DAOand then double-click the selected text to go to the "Accessing External Databases with DAO" topic.
Article ID: 146406 - Last Review: October 11, 2006 - Revision: 2.3
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.