6,210
社区成员
发帖
与我相关
我的任务
分享
Sub test()
Set Cnn = CreateObject("adodb.connection")
h = 2
f = Dir(ThisWorkbook.Path & "\*.xls")
Do While f > " "
If f <> ThisWorkbook.Name Then
Cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.Path & "\" & f
Sql = "select 完成定额 from [月公示$] where 姓名 = 张三"
Cells(a, 1).CopyFromRecordset Cnn.Execute(Sql)
'每次到这里就出错,一直查不明白原因。
ed = [b65536].End(3).Row + 1
Cells(h, 1).Resize(ed - h, 1) = f
h = ed
Cnn.Close
'断开cnn的链接
End If
f = Dir
Loop
End Sub