|
- Sub aa()
- Dim cnn As Object, pPath$, temp$, myPath$, j&, shtName$, sql$
- pPath = ThisWorkbook.Path & "\品种日周期"
- Set cnn = CreateObject("ADODB.Connection")
- With cnn
- If Application.Version = "11.0" Then
- .Provider = "microsoft.jet.oledb.4.0"
- .ConnectionString = "extended properties=""excel 8.0;HDR=yes;"";data source=" & ThisWorkbook.FullName
- Else
- .Provider = "microsoft.ACE.oledb.12.0"
- .ConnectionString = "extended properties=""excel 12.0;HDR=yes;"";data source=" & ThisWorkbook.FullName
- End If
- .Open
- End With
-
- myPath = pPath
- temp = Dir(myPath & "*.xls")
-
- Do While temp <> ""
- If InStr(temp, "指数") > 0 Then
- shtName = Split(temp, ".")(0)
- sql = "select * from [Excel 12.0;hdr=no;Database=" & myPath & temp & ";].[" & shtName & "$E:E]"
- j = j + 1
- Sheet2.Cells(1, j).Value = shtName
- Sheet2.Cells(2, j).CopyFromRecordset cnn.Execute(sql)
- End If
- temp = Dir
- Loop
- Set cnn = Nothing
- End Sub
复制代码 |
|