Sub GetDataFromDBF()
Dim cnn As ADODB.Connection
Dim cnnStr As String
Dim SQL As String
Dim rs As ADODB.Recordset
Dim ws As Worksheet
Set cnn = New ADODB.Connection
cnnStr = "Driver={Microsoft Visual Foxpro Driver};Sourcetype=dbf;SourceDB=Path;Exclusive=NO"
cnn.ConnectionString = cnnStr
On Error Resume Next
cnn.Open
SQL = "select * from XX.dbf"
Set rs = New ADODB.Recordset
Set rs = cnn.Execute(SQL)
Set ws = ThisWorkbook.ActiveSheet
ws.Range("A2").CopyFromRecordset rs
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
Set ws = Nothing
End Sub
GetDataFromDBF
最新推荐文章于 2024-11-12 11:22:09 发布