1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Dim Source_1 As ADODB.Connection
Dim Requete As ADODB.Recordset
Dim Fichier_1, xSQL As String
Dim i As Long
xSQL = "requete ..."
Set Source_1 = New ADODB.Connection
Source_1.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Fichier_1 & ";Extended Properties=""Excel 12.0;" & "HDR=YES;IMEX=1;"""
Set Requete = New ADODB.Recordset
Set Requete = Source_1.Execute(xSQL)
For i = 0 To Requete.Fields.Count - 1
Cells(1, i + 1) = Requete.Fields(i).Name
Next
Feuil3.Range("A2").CopyFromRecordset Requete
Source_1.Close
Set Source_1 = Nothing
Set Requete = Nothing |
Partager