引用这个宏文件xlodbc.xla,就可以通过下面的方法去访问我们建立的数据源了 Sub opendb() Dim id as integer id = SQLOpen("DSN=pubs") SQLExecQuery id, “select * from authors” Set output = Worksheets("Sheet1").Range("A1") SQLRetrieve id, output, , , True SQLClose id End sub 第二句是调用xlodbc.xla宏中的SQLOpen函数建立一个对数据库pubs连接,第三句是SQLExecQuery函数执行了一条select语句,id是由 SQLOpen 函数返回的唯一连接标识,第四句是SQLRetrieve函数将SQLExecQuery函数执行的查询的结果返回到Excel