ImportVFPData() ImportVFPData()
Dim i%, sql$
Dim cn, rst
Set cn = CreateObject( "adodb.connection")
Set rst = CreateObject( "adodb.recordset")
Dim sql As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='dbase 5.0';Data Source=" & ThisWorkbook.Path
sql = "SELECT * FROM sales.dbf WHERE name='A'"
rst.Open sql, cn
With Sheet1
.UsedRange.ClearContents
For i = 1 To rst.Fields.Count
.Cells(1, i) = rst.Fields(i - 1).Name
Next i
.Range( "A2").CopyFromRecordset rst
End With
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Sub
Dim i%, sql$
Dim cn, rst
Set cn = CreateObject( "adodb.connection")
Set rst = CreateObject( "adodb.recordset")
Dim sql As String
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='dbase 5.0';Data Source=" & ThisWorkbook.Path
sql = "SELECT * FROM sales.dbf WHERE name='A'"
rst.Open sql, cn
With Sheet1
.UsedRange.ClearContents
For i = 1 To rst.Fields.Count
.Cells(1, i) = rst.Fields(i - 1).Name
Next i
.Range( "A2").CopyFromRecordset rst
End With
rst.Close
cn.Close
Set rst = Nothing
Set cn = Nothing
End Sub
作者:laoyebin(Paladin.lao)
个人网站英文出处:
http://mrvsto.com/
个人网站中文出处:
http://cn.mrvsto.com/
转载于:https://blog.51cto.com/laoyebin/360486