# Re: 请问各位VB高手,vb可用excel来当资料库吗?

Posted by yeong huann on August 07, 1998 at 17:04:33:

In Reply to: 请问各位VB高手,vb可用excel来当资料库吗? posted by TIM on August 07, 1998 at 13:53:31:

: 请问各位VB高手,vb可用excel来当资料库吗?
: 若可以,如何连结到EXCEL呢
: 还有如何抓excel栏位资料呢
: 因为我有资料抓到资料库后便要加总及平均等运算
: 谢谢赐教

你可以在目前使用的资料库中新增一个Tabledef物件,再透过此物件的Connect及SourceTableName属性指定所要连结的试算表档案.即可

ex:
dim db as database
dim tfd as tabledef
dim rst as recordset

set db=opendatabase("c:\test.mdb")
set tfd=db.createtabledef("someexcel")
tdf.connect="excel 5.0;database=\\data\al.xls"
tdf.sourcetablename="sample"
db.tabledefs.append tdf
set res=db.openrecordset("someexcel")

Follow Ups: