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
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim appexcel As Excel.Application
Dim wbexcel As Excel.Workbook
'Dim erreurnom = MessageBox.Show("Il y'a une différence de nom entre la table Access et la feuille de données Excel", "Attention !")
appexcel = CreateObject("Excel.application")
wbexcel = appexcel.Workbooks.Open("file.xls")
'wbexcel.ReadOnly = True
appexcel.Visible = True
'i correspond à la première cellule où on va mettre les cotes
Dim i As Byte
i = "10"
Dim j As Byte
'j = au nombre d'enregistrement dans le dataset !
For j = 0 To dts.Tables("BA3_S1").Rows.Count - 1
'contrôle du nom de l'étudiant
appexcel.Cells(i, " 45") = dtt.Rows(rownum).Item("Nomcomplet")
'TH
If appexcel.Cells(i, " 45").value = appexcel.Cells(i, " 2").value Then
appexcel.Cells(i, " 4") = dtt.Rows(rownum).Item("cours1")
'Analyse Instrumentale
appexcel.Cells(i, " 5") = dtt.Rows(rownum).Item("cours2")
'Else
'MessageBox.Show(erreurnom)
' End If
i = i + 1
'on va un enregistrement plus loin (rst.movenext en DAO ou ADO)
Else
MessageBox.Show("Les informations entre Excel et Access sont différentes", "Attention")
Exit Sub
End If
rownum += 1
Next j
MessageBox.Show("Importation terminée et contrôlée", "Information")
cnn = Nothing
dts = Nothing
End Sub |
Partager