dim dbcon as adodb.connection
dim dbrec as adodb.recordset
dim dbsql as string
dim i as long
set dbcon = new adodb.connection
set dbrec = new adodb.recordset
if dbrec.recordcount()>0 then
do while not dbrec.eof()
sheet1.cells(i,1)=dbrec(0) '这里的I是行号,1,2,3是你要取出的字段,可以根据需要增加
sheet1.cells(i,2)=dbrec(1)
sheet1.cells(i,3)=dbrec(2)
i=i+1
loop
endif
dbrec.close
dbcon.close
set dbrec=nothing
set dbcon=nothing
msgbox "共导入:" & i &"条记录"