1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
Dim i As Integer
Dim path As String
Set xlwbook = xl.Workbooks.Open(App.path & "\" & CheminFichierExcel2)
Set xlsheet = xlwbook.Sheets.Item(1)
path = App.path
path = path & FichierDB
Set cnx = New ADODB.Connection
Set rst = New ADODB.Recordset
'Définition du pilote de connexion
cnx.Provider = "Microsoft.Jet.OLEDB.4.0"
'Définition de la chaîne de connexion
cnx.ConnectionString = path
cnx.Open
rst.Open ReqGalaad, cnx
'On commence à remplir la feuille EXCEL à partir de la ligne 2
i = 1
While Not (rst.EOF)
xlsheet.Cells(i, 1) = rst("NOM")
xlsheet.Cells(i, 2) = rst("PRENOM")
xlsheet.Cells(i, 3) = rst("CP")
xlsheet.Cells(i, 4) = rst("COMMUNE")
xlsheet.Cells(i, 5) = rst("DIGIMEDIA.C_RET")
xlsheet.Cells(i, 6) = rst("PREFIXE")
xlsheet.Cells(i, 7) = rst("CARTE")
xlsheet.Cells(i, 8) = rst("Q_TITRES_AGO")
xlsheet.Cells(i, 9) = rst("Q_TITRES_AGE")
xlsheet.Cells(i, 10) = rst("N_ASSEMBLE")
xlsheet.Cells(i, 11) = rst("N_PARTICIP")
xlsheet.Cells(i, 12) = rst("L_NOM_TITULAIRE")
xlsheet.Cells(i, 13) = rst("L_PREN_TITULAIRE")
xlsheet.Cells(i, 14) = rst("SQL1_TA0BZF.C_RET")
xlsheet.Cells(i, 15) = rst("C_PREFIX")
xlsheet.Cells(i, 16) = rst("N_CARTE")
xlsheet.Cells(i, 17) = rst("Q_TITRES")
xlsheet.Cells(i, 18) = rst("Q_VOIX")
xlsheet.Cells(i, 19) = rst("I_PRESENT")
xlwbook.Save
rst.MoveNext
i = i + 1
Wend
rst.Close
cnx.Close
xl.ActiveWorkbook.Close False, App.path & "\" & CheminFichierExcel2
xl.Quit |
Partager