Private Sub Command1_Click()
Call PutInExcel1("10")
End Sub
Sub PutInExcel1(i)
'==================================
Dim conn As New ADODB.Connection
Dim rs As ADODB.Recordset
FileName = "D:\database\db.mdb"
CnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Persist Security Info=False"
conn.Open CnStr
'==================================
Dim ExlApp As New Excel.Application
ExlFile = "D:\Database\test.xls"
ExlApp.Workbooks.Open (ExlFile)
ExlApp.Worksheets("blad1").Select
'==================================
Sql = "select a.* from list a where a.[chart no]='" & i & "' and a.[site-measurement]='1 - Depth'"
Print Sql
rs.Open Sql, conn, 1, 1
If rs(3) <> "missing" Then ExlApp.Cells(17, 3) = rs(3)
If rs(4) <> "missing" Then ExlApp.Cells(17, 6) = rs(4)
If rs(5) <> "missing" Then ExlApp.Cells(17, 9) = rs(5)
ExlApp.SaveWorkspace
ExlApp.Quit
rs.Close
conn.Close
End Sub
到底我做错什么了????
忽然笑
交互式爱情
潇湘沐