On the Developer ribbon, you??™ll find quick
access to Microsoft Access databases, web tables, and text files. Excel also includes data access
to SQL Server and OLAP databases, XML data, and ODBC data sources.
By recording macros, you can see how Excel connects us to various data sources. From
there, you??™ll begin writing your own data access routines.
nNote The first few examples will run under Windows 2000 or Windows XP as is. Windows Vista still
supports Visual Basic 6.0 (and by extension VBA), but does not ship with all of the data access components
of its predecessors. To run the examples under Windows Vista, check the following link to Microsoft??™s
Support Statement for Visual Basic 6.0 on Windows Vista: http://msdn2.microsoft.com/en-us/vbrun/
ms788708.aspx.
Importing Access Data
Let??™s look at how Excel brings in external data by recording a quick macro to import data from
an Access database.
Create a new macro named GetAccessData. We??™re going to import the Extended Employees
list (query) from the Northwind 2007 database onto Sheet1 in a new Excel workbook.
1. Select the Data ribbon.
2. Select From Access from the Get External Data section of the Data ribbon.
3. Navigate to wherever you have the Northwind database stored.
43
C H A P T E R 2
nNote The files for these examples can be found in the Source Code/Download section of this book??™s
home page at www.apress.com.
nNote There is a new version of Northwind in Access 2007 that uses a file extension of *.
Pages:
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70