You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .

You need to set a reference to "Microsfot ActiveX Data Objects" (ADO for short) first.

In the VBE select Tools -> References... From the dialog box that pops up, scrolll down until you find an entry that reads something like Microsfot ActiveX Data Objects 2.7 Library (the number might be different - pick the highest number you can see). Check the tick box next to this entry and then click ok. You should be good to go now.