System.Runtime.InteropServices.COMException (0x8002000B): Index non valide. (Exception de HRESULT : 0x8002000B (DISP_E_BADINDEX))
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
' enregister et envoyé
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Dim nom_fichier As String
Dim madate = CStr(Date.Today)
Dim fichierexiste
Dim i
Dim xlUp = 0
Dim numhot As Integer
madate = Replace(madate, "/", "-")
madate = Mid(madate, 4)
nom_fichier = ("c:\hotline" & madate & " " & mesinfos.TextBox2.Text)
fichierexiste = My.Computer.FileSystem.FileExists("c:\hotline" & madate & " " & mesinfos.TextBox2.Text & ".xls")
'contole de format des données
If mesinfos.TextBox2.Text = "" Then
info.Text = "Veuillez remplir le champs ITC dans mes infos."
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If ComboBox4.Text "" Or ComboBox4.Text "Temps Passée" Then
info.Text = "Veuillez sélectionner un TEMPS"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If ComboBox2.SelectedIndex = 0 Then
info.Text = "Veuillez sélectionner un Département"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If TextBox1.Text = "" Then
info.Text = "Veuillez remplir le champs Société"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If TextBox2.Text = "" Then
info.Text = "Veuillez remplir le champs Contact"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If IsNumeric(TextBox7.Text) = False Then
info.Text = "un Code Agence est composé de chiffres !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If IsNumeric(TextBox4.Text) = False Then
info.Text = "un Compte SOON est composé de chiffres !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If ComboBox3.SelectedIndex = 0 Then
info.Text = "Veuillez sélectionner une Famille Produit"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If TextBox3.Text = "" Then
info.Text = "Veuillez remplir le champs Demandeur hotline"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If TextBox6.Text = "" Then
info.Text = "Veuillez remplir le champs Questions"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If TextBox8.Text = "" Then
info.Text = "Veuillez remplir le champs Réponses"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If CheckBox1.Checked = True Then
If TextBox9.Text "" And CheckBox1.Checked True Then
info.Text = "l'adresse mail Demandeur est invalide..."
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
End If
If mesinfos.TextBox5.Text "" And CheckBox1.Checked True Then
info.Text = "l'adresse mail ITC est invalide..."
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If CheckBox1.Checked = True Then
If TextBox9.Text Like "?*@?*.??*" Then
Else
info.Text = "l'adresse mail du demandeur est invalide !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If nbrcaractere.NbOc(TextBox9.Text, "@", False) > 1 Then
info.Text = "l'adresse mail du demandeur est invalide !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
End If
If mesinfos.TextBox12.Text "" And CheckBox1.Checked True Then
info.Text = "User invalide...Voir dans mes infos !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If mesinfos.TextBox11.Text "" And CheckBox1.Checked True Then
info.Text = "Password invalide...Voir dans mes infos !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
If mesinfos.TextBox13.Text "" And CheckBox1.Checked True Then
info.Text = "SMTP invalide...Voir dans mes infos !"
System.Windows.Forms.Application.DoEvents()
Exit Sub
End If
'enregistrement des données
If fichierexiste Then
If CheckBox1.Checked = True Then
testconnexion.testconnexion()
If testok = True Then
If CheckBox3.Checked = False Then
principal.destinatairemail = TextBox9.Text
Else
principal.destinatairemail = TextBox9.Text & ";" & mesinfos.TextBox5.Text
End If
principal.entetemail = "réponse de votre demande de hotline"
principal.messagemail = "Bonjour," & vbLf & vbLf & "Veuillez trouver ci-dessous notre réponse :" & vbLf & vbLf & "ITC de Hotline : " & (mesinfos.TextBox2.Text) & vbLf & vbLf & "Date : " & (DateTimePicker1.Text) & vbLf & vbLf & "Client : " & (TextBox1.Text) & vbLf & vbLf & "Contact : " & (TextBox2.Text) & vbLf & vbLf & "TEL : " & (TextBox14.Text) & vbLf & vbLf & "Code Soon : " & (TextBox4.Text) & vbLf & vbLf & "Question : " & vbLf & (TextBox6.Text) & vbLf & vbLf & "Réponse : " & vbLf & (TextBox8.Text) & vbLf & vbLf & "Action Commerciale à mener : " & (TextBox10.Text) & vbLf & vbLf & "Temps Passée : " & (ComboBox4.Text) & " .Minutes" & vbLf & vbLf & vbLf & "Vous en Souhaitant Bonne Réception." & vbLf & "Cordialement." & vbLf & vbLf & (mesinfos.TextBox2.Text)
principal.piecejointemail = Label11.Text
envoimail.envoimail()
If mailok = True Then
Else
Exit Sub
End If
Else
Exit Sub
End If
End If
'Create a new instance of Excel
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(Filename:=nom_fichier & ".xls")
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 & ".xls")
oExcel.Quit()
oExcel.DisplayAlerts = True
oExcel = Nothing
oBook = Nothing
KillProcessus.KillProcessus("Excel")
Exit Sub
Else
With oExcel.Sheets("suivi hotline")
i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("suivi hotline").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), " ")
.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
'attribution n° hotline
If (.cells((i - 1), 16).value) < 1 Then
.cells(i, 16).value = 1
Else
.cells(i, 16).value = (.cells((i - 1), 16).value) + 1
numhot = .cells(i, 16).value
End If
'autoajustage des colonnes
.Cells.Columns.AutoFit()
'fermeture des instances Excel
oExcel.DisplayAlerts = False
If Val(oExcel.Version) > 11 Then
oBook.Saveas(Filename:=nom_fichier, FileFormat:=56)
Else
oBook.Saveas(Filename:=nom_fichier & ".xls")
End If
oBook.close(Filename:=nom_fichier & ".xls")
oExcel.Quit()
oExcel.DisplayAlerts = True
oSheet = Nothing
oExcel = Nothing
oBook = Nothing
KillProcessus.KillProcessus("Excel")
info.Text = "Enregistrement réussi !"
System.Windows.Forms.Application.DoEvents()
MsgBox("Votre N° de hotline local est : " & numhot, MsgBoxStyle.Information, AcceptButton)
Timer3.Enabled = True
End With
Exit Sub
End If
Else
If CheckBox1.Checked = True Then
testconnexion.testconnexion()
If testok = True Then
If CheckBox3.Checked = False Then
principal.destinatairemail = TextBox9.Text
Else
principal.destinatairemail = TextBox9.Text & ";" & mesinfos.TextBox5.Text
End If
'appel du module pour espace tel.
telephone = TextBox14.Text
ESPACE.espace(telephone, TextBox14.Text)
System.Windows.Forms.Application.DoEvents()
principal.entetemail = "réponse de votre demande de hotline"
principal.messagemail = "Bonjour," & vbLf & vbLf & "Veuillez trouver ci-dessous notre réponse :" & vbLf & vbLf & "ITC de Hotline : " & (mesinfos.TextBox2.Text) & vbLf & vbLf & "Date : " & (DateTimePicker1.Text) & vbLf & vbLf & "Client : " & (TextBox1.Text) & vbLf & vbLf & "Contact : " & (TextBox2.Text) & vbLf & vbLf & "TEL : " & (TextBox14.Text) & vbLf & vbLf & "Code Soon : " & (TextBox4.Text) & vbLf & vbLf & "Question : " & (TextBox6.Text) & vbLf & vbLf & "Réponse : " & (TextBox8.Text) & vbLf & vbLf & "Action Commerciale à mener : " & (TextBox10.Text) & vbLf & vbLf & "Temps Passée : " & (ComboBox4.Text) & " .Minutes" & vbLf & vbLf & vbLf & "Vous en Souhaitant Bonne Réception." & vbLf & "Cordialement." & vbLf & vbLf & (mesinfos.TextBox2.Text)
principal.piecejointemail = Label11.Text
envoimail.envoimail()
If mailok = True Then
Else
Exit Sub
End If
Else
Exit Sub
End If
End If
'Create a new instance of Excel
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
oSheet = oExcel.ActiveSheet
With oExcel.Sheets("Feuil1")
i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("feuil1").Columns(1))
i = i + 1.0
' demandeur
.Cells(i, 1).Value = "DEMANDEUR"
'noms ITC
.Cells(i, 2).Value = "NOMS ITC"
' date
.Cells(i, 3).Value = "DATE"
' temps passée
.Cells(i, 4).Value = "TEMPS"
' client
.Cells(i, 5).Value = "CLIENT"
' contact client
.Cells(i, 6).Value = "CONTACT"
' N° SOON
.Cells(i, 7).Value = "N° SOON"
' code agence
.Cells(i, 8).Value = "CODE AGENCE"
'noms DEPARTEMENT
.Cells(i, 9).Value = "DEPARTEMENT"
' famille
.Cells(i, 10).Value = "FAMILLE"
'Questions
.Cells(i, 11).Value = "QUESTIONS"
'Réponse
.Cells(i, 12).Value = "REPONSE"
.Cells(i, 13).Value = "Email Demandeur"
'action
.Cells(i, 14).Value = "Action Commerciale ?"
'telephone
.Cells(i, 15).Value = "Tel Client"
'num hot
.Cells(i, 16).Value = "NUM HOTLINE"
i = i + 1
' 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), " ")
.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
'attribution n° hotline
.cells(i, 16).value = 1
numhot = .cells(i, 16).value
.name = "suivi hotline" ' renomage de l'onglet
'autoajustage des colonnes
.Cells.Columns.AutoFit()
End With
With oExcel.Sheets("Feuil2")
i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("Feuil2").Columns(1))
i = i + 1.0
'creation nombre de demande incorrect
.Cells(i, 1).Value = "Demande Hotline incorrect"
' demandeur
.Cells(i, 2).Value = "DEMANDEUR"
'noms ITC
.Cells(i, 3).Value = "NOMS ITC"
' date
.Cells(i, 4).Value = "DATE"
.name = "demande incorrecte"
'autoajustage des colonnes
.Cells.Columns.AutoFit()
End With
With oExcel.Sheets("Feuil3")
i = oExcel.WorksheetFunction.CountA(oExcel.Worksheets("feuil3").Columns(1))
i = i + 1.0
' demandeur
.Cells(i, 1).Value = "DEMANDEUR"
'noms ITC
.Cells(i, 2).Value = "NOMS ITC"
' date
.Cells(i, 3).Value = "DATE"
' temps passée
.Cells(i, 4).Value = "TEMPS"
' client
.Cells(i, 5).Value = "CLIENT"
' contact client
.Cells(i, 6).Value = "CONTACT"
' N° DEVIS
.Cells(i, 7).Value = "N°DEVIS"
' MONTANT
.Cells(i, 8).Value = "MONTANT"
'noms DEPARTEMENT
.Cells(i, 9).Value = "DEPARTEMENT"
' famille
.Cells(i, 10).Value = "FAMILLE"
'Descriptif
.Cells(i, 11).Value = "DESCRIPTIF"
'telephone
.Cells(i, 12).Value = "Tel Client"
'implication avv
.Cells(i, 13).Value = "AVV Client"
'implication Définiton Produits
.Cells(i, 14).Value = "Définiton Produits"
'Validation Produits
.Cells(i, 15).Value = "Validation Produits"
'Relance Affaire
.Cells(i, 16).Value = "Suivi Affaire"
'Saisie Soon
.Cells(i, 17).Value = "Saisie Soon"
'Réserve
.Cells(i, 18).Value = "Traitement Solo"
.name = "suivi affaire" ' renomage de l'onglet
'autoajustage des colonnes
.Cells.Columns.AutoFit()
'fermeture des instances Excel
oExcel.DisplayAlerts = False
If Val(oExcel.Version) > 11 Then
oBook.Saveas(Filename:=nom_fichier, FileFormat:=56)
Else
oBook.Saveas(Filename:=nom_fichier & ".xls")
End If
oBook.close(Filename:=nom_fichier & ".xls")
oExcel.Quit()
oExcel.DisplayAlerts = True
oSheet = Nothing
oExcel = Nothing
oBook = Nothing
KillProcessus.KillProcessus("Excel")
End With
info.Text = "Enregistrement réussi !"
System.Windows.Forms.Application.DoEvents()
MsgBox("Votre N° de hotline local est : " & numhot, MsgBoxStyle.Information, AcceptButton)
Timer3.Enabled = True
End If
End Sub