Open excel, right-click "sheet1", select "view code" at the bottom of the menu, and copy the script to the vbscript editor, click "tools-Reference", select Microsoft ActiveX Date Objects 2.8, and click "OK". Then run the code.
Public Function daadfa ()
'First reference ado --------- click "tool-reference" and then find Microsoft ActiveX Date Objects X. X Library
Dim conn As New ADODB. Connection, connstr As String, db As String, rs As New ADODB. Recordset, I As Long, rows As Long
Db = "C: \ 1 \ db. mdb"
Connstr = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & db
On Error Resume Next
Conn. Open connstr
Rs. Open "select * from userinfo", conn, 1, 3
If rs. EOF Or rs. BOF Then
MsgBox "It is nothing ."
Else
'If the username value in access is equal to Seven, put the userid value of the original record in the 10th rows and 10th columns of the excel table.
'If rs ("username") = "Seven" Then
'Worksheets ("sheet1"). Cells (10, 10). Value = rs ("userid ")
'End If
'Capture the criteria of no column in access using the operator and store them in the first row of the sheet 1 worksheet in excel.
Rows = 1
For I = 0 To rs. Fields. Count-1
Worksheets ("sheet1"). Cells (1, rows). Value = rs. Fields (I). Name
Next I
'Capture the numbers corresponding to each column in the access using the cyclical method.
Do Until rs. EOF
For I = 0 To rs. Fields. Count-1
Worksheets ("sheet1"). Cells (I + 2, rows). Value = rs (I)
Next I
Rows = rows + 1
Rs. MoveNext
Loop
End If
End Function