Here's where it all comes together. This section combines the understanding of Excel programming that you've gained from previous chapters with the SQL and ADO techniques discussed so far in this chapter. Excel applications frequently require data from outside sources. The most common of these sources are Access and SQL Server databases. However, I've created applications that required source data from mainframe text file dumps and even Excel workbooks. As you'll see, ADO makes acquiring data from these various data sources easy.
To run the code examples shown in the sections that follow, you must set a reference from your Excel project to the ADO 2.5 Object Library. To do this, bring up the References dialog by selecting the Tools O References menu item from within the VBE. Scroll down until you locate the entry labeled Microsoft ActiveX Data Objects 2.5 Library. Place a check mark beside this entry and click OK (see Figure 20-4).
References - VBAProject
□ Microsoft ACT Test Object Model 1.0 Type Library | a] O Microsoft Active Server Pages Object Library
□ Microsoft Active Server Pages Object Library
□ Microsoft Active Server Pages ObjectContext Object D Microsoft ActiveMovie Control
□ Microsoft ActiveX Data Objects (Multi-dimensional) 2.'—1
□ Microsoft ActiveX Data Objects 2.0 Library
□ Microsoft ActiveX Data Objects 2.1 Library
✓ Microsoft ActiveX Data Objects 2.5 Library )
□ Microsoft ActiveX Data Objects 2.6 Library
□ Microsoft ActiveX Data Objects 2.7 Library
□ Microsoft ActiveX Data Objects 2.8 Library
D Microsoft ActiveX Data Objects Recordset 2.5 Library—i l~l Mirrnsnfh ArNveX Pli inin U^J
Microsoft ActiveX Data Objects 2.5 Library
Location : C : \Program Files\Common Files\System\ado\msado25. tlb Language: Standard
Note that it's perfectly normal to have multiple versions of the ADO object library available.
Was this article helpful?