[VB6]: Inscrire donnée dans une table excel
Bonjour à tous
voila j'ai fait un petit programme simple
j'ai 17 textbox dans ma form
j'ai un bouton qui permet d'ouvrir un fichier excel et j'ai un autre bouton qui inscrit les données des listbox dans ma table excel et c'est cette dernière opération qui ne fonctionne pas. j'ai un msg d'erreur qui me dit variable objet ou bloc with non définis et il me surligne la ligne en jaune
Code:
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 48 49 50 51 52 53 54 55 56 57
|
Private Sub Command2_click()
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
Set appExcel = CreateObject("Excel.Application")
appExcel.Workbooks.Add
Set wbExcel = appExcel.ActiveWorkbook
Set wsExcel = wbExcel.ActiveSheet
appExcel.Visible = True
End Sub
Private Sub Command1_Click()
Dim I As Integer, var As Integer
Dim val As String, typ As String
Dim Rapports(2) As Double
Command1.Enabled = True
'Texte rajouté pour le stockage dans excel
Dim appExcel As Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
Static J As Long
J = J + 1
'Inscrit le type des 4 composants sous excel
wsExcel.Cells(3 + 3 * J, 1) = Text1(0).Text
wsExcel.Cells(3 + 3 * J, 2) = Text1(1).Text
wsExcel.Cells(3 + 3 * J, 3) = Text1(2).Text
wsExcel.Cells(3 + 3 * J, 4) = Text1(3).Text
'Inscrit le taux des 4 composants sous excel
wsExcel.Cells(4 + 3 * J, 1) = Text2(0).Text
wsExcel.Cells(4 + 3 * J, 2) = Text2(1).Text
wsExcel.Cells(4 + 3 * J, 3) = Text2(2).Text
wsExcel.Cells(4 + 3 * J, 4) = Text2(3).Text
'Inscrit le poids des 4 composants
wsExcel.Cells(5 + 3 * J, 1) = Text2(0).Text
wsExcel.Cells(5 + 3 * J, 2) = Text2(1).Text
wsExcel.Cells(5 + 3 * J, 3) = Text2(2).Text
wsExcel.Cells(5 + 3 * J, 4) = Text2(3).Text
'Inscrit le code de chaque composant sous excel
wsExcel.Cells(6 + 3 * J, 1) = Text3(0).Text
wsExcel.Cells(6 + 3 * J, 2) = Text3(1).Text
wsExcel.Cells(6 + 3 * J, 3) = Text3(2).Text
wsExcel.Cells(6 + 3 * J, 4) = Text3(3).Text
'Inscrit le numéro de la machine
wsExcel.Cells(1, 1) = Text5.Text
End Sub |