我用ADO的方法link SQL Server,並欲將某一查詢出來的筆數,
放到excel儲存格裡,但發生「引數型態錯誤,或超過可接受的範圍」的這樣的訊息。(可呼叫Excel),我的問題是:如何將sql查詢的結果放到excel工作表?請各位指正小弟的錯誤何在?
我的語法如下:
Private Sub Command1_Click()
Dim ObjExcel As Excel.Application
Set ObjExcel = New Excel.Application
ObjExcel.Visible = True
ObjExcel.Workbooks.Add
Dim strSQL As Variant
strSQL = "select * from offday"
Set rs = New ADODB.Recordset
rs.Open cn, strSQL, adOpenStatic
ObjExcel.Cells(1, 1) = rs.field(0)
Set ObjExcel = Nothing
End Sub