隨筆2
Sub access_test()
Dim CONN As Object
Dim RST As Object
Dim SQL As String
Sheets("Sheet1").Cells.Clear
Set CONN = CreateObject("adodb.connection")
Set RST = CreateObject("adodb.recordset")
SQL = "select * from 律師函8月分"
CONN.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.Path & "\新建 Microsoft Access 數(shù)據(jù)庫(kù).accdb" & ";ACE OLEDB:Database Password="
Set RST = CONN.Execute(SQL)
For i = 1 To RST.Fields.Count
Cells(1, i) = RST.Fields(i - 1).Name
Next
Sheets("Sheet1").[a2].CopyFromRecordset RST
CONN.Close
Set C0NN = Nothing
End Sub