呵呵,在MS的新闻组上看到的,虽然我们平时学习ADO时都知道有怎么个方法,但是关键时候要想起来还是很困难的,让你不用Excel.Application你能想到ADO吗?
示例代码
Dim oADO, oRS, sSQL, sConn
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Ray\SomeExcelFile.xls;Extended Properties=""Excel
8.0;HDR=Yes;IMEX=1"""
sSQL = "SELECT this, that FROM "
Set oADO = CreateObject("ADODB.Connection")
oADO.Open sConn
Set oRS = oADO.Execute(sSQL)
If Not oRS.EOF Then WScript.Echo oRS.GetString(2,,",",vbCRLF,"")
oRS.Close : Set oRS = Nothing
oADO.Close : Set oADO = Nothing
Last edited by electronixtar on 2006-8-27 at 15:41 ]
Hehe, saw it on MS newsgroup. Although we all know how to use ADO when learning it normally, it's still difficult to recall it in critical moments. Can you think of ADO without using Excel.Application?
Sample code
Dim oADO, oRS, sSQL, sConn
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Ray\SomeExcelFile.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
sSQL = "SELECT this, that FROM "
Set oADO = CreateObject("ADODB.Connection")
oADO.Open sConn
Set oRS = oADO.Execute(sSQL)
If Not oRS.EOF Then WScript.Echo oRS.GetString(2,,",",vbCRLF,"")
oRS.Close : Set oRS = Nothing
oADO.Close : Set oADO = Nothing
Last edited by electronixtar on 2006-8-27 at 15:41 ]