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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(Filename:=nom_fichier)
oSheet = oExcel.ActiveSheet
If oBook.ReadOnly = True Then
info.Text = "le fichier est déjà ouvert, veuillez fermer le fichier et Excel !"
System.Windows.Forms.Application.DoEvents()
oExcel.DisplayAlerts = False
oBook.close(Filename:=nom_fichier)
oExcel.Quit()
oExcel.DisplayAlerts = True
oExcel = Nothing
oBook = Nothing
Exit Sub
Else
With oExcel.Sheets("suivi")
i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("suivi").Columns(1))
i = i + 1.0
' demandeur
.Cells(i, 1).Numberformat = "@" 'Cellules au format texte
.Cells(i, 1).Value = TextBox3.Text
'noms ITC
.Cells(i, 2).Numberformat = "@" 'Cellules au format texte
.Cells(i, 2).Value = mesinfos.TextBox2.Text
' date
.Cells(i, 3).Value = DateTimePicker1.Text
' Temps passée
.Cells(i, 4).Value = ComboBox4.Text
' client
.Cells(i, 5).Numberformat = "@" 'Cellules au format texte
.Cells(i, 5).Value = TextBox1.Text
' contact client
.Cells(i, 6).Numberformat = "@" 'Cellules au format texte
.Cells(i, 6).Value = TextBox2.Text
' N° SOON
.Cells(i, 7).Value = TextBox4.Text
' code agence
.Cells(i, 8).Value = TextBox7.Text
'noms DEPARTEMENT
.Cells(i, 9).Numberformat = "@" 'Cellules au format texte
.Cells(i, 9).Value = ComboBox2.Text
' famille
.Cells(i, 10).Numberformat = "@" 'Cellules au format texte
.Cells(i, 10).Value = ComboBox3.Text
'Questions
.Cells(i, 11) = Replace(TextBox6.Text, Chr(13) & Chr(10), " ")
'Réponse
.Cells(i, 12) = Replace(TextBox8.Text, Chr(13) & Chr(10), " ")
'email
.Cells(i, 13).Numberformat = "@" 'Cellules au format texte
.Cells(i, 13).Value = TextBox9.Text
'action
.Cells(i, 14).Value = TextBox10.Text
'téléphone
'appel du module pour espace tel.
telephone = TextBox14.Text
ESPACE.espace(telephone, TextBox14.Text)
System.Windows.Forms.Application.DoEvents()
.Cells(i, 15).Numberformat = "@" 'Cellules au format texte
.Cells(i, 15).Value = TextBox14.Text
'autoajustage des colonnes
.Cells.Columns.AutoFit()
'fermeture des instances Excel
oExcel.DisplayAlerts = False
oBook.Saveas(Filename:=nom_fichier)
oBook.close(Filename:=nom_fichier)
oExcel.Quit()
oExcel.DisplayAlerts = True
oSheet = Nothing
oExcel = Nothing
oBook = Nothing
End if |
Partager