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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
Option Explicit 'on oblige le prg à utiliser des variables déclarées
Dim Ws As Worksheet 'déclare Ws comme étant une variable feuille
'Pour le formulaire
Private Sub UserForm1_Initialize()
Dim J As Long 'J variable de comptage
Dim I As Integer 'I variable
Set Ws = Sheets("Historique pannes") 'On déclare Ws comme étant la feuille Historique pannes
With Me.ComboBox13 'XXX
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row0
.AddItem Ws.Range("A" & J)
Next J
End With
For I = 1 To 12
Me.Controls("TextBox" & I).Visible = True
Next I
End Sub
'Numéro de la panne Bug venant surement d'ici
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim Tablo As Integer
Ligne = Me.ComboBox1.ListIndex + 2
ComboBox1 = Ws.Cells(Ligne, "B")
For I = 1 To 12
Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I + 2)
Next I
End Sub
'Pour le bouton Nouvelle panne
Private Sub CommandButton1_Click()
Dim L As Integer
If MsgBox("Confirmez-vous la demande d'intervention ?", vbYesNo, "Demande deconfirmation dintervention") = vbYes Then
L = Sheets("Historique pannes").Range("a65536").End(xlUp).Row + 1 'Pour placer le nouvel enregistrement à la première ligne de tableau non vide
Range("A" & L).Value = ComboBox1
Range("B" & L).Value = TextBox9
Range("C" & L).Value = TextBox10
Range("D" & L).Value = TextBox1
Range("E" & L).Value = TextBox6
Range("F" & L).Value = TextBox2
Range("G" & L).Value = TextBox3
Range("H" & L).Value = TextBox4
Range("I" & L).Value = TextBox7
Range("J" & L).Value = "Fonctionnalité à venir"
Range("K" & L).Value = TextBox8
Range("L" & L).Value = TextBox12
Range("M" & L).Value = TextBox11
End If
If 1 = 1 Then Envoimail
retour:
End Sub
'Envoi d'un mail service maintenance FONCTIONNE
Sub Envoimail()
'Dim Mail As New Message
'Dim Config As Configuration: Set Config = Mail.Configuration
'Config(cdoSendUsingMethod) = cdoSendUsingPort
'Config(cdoSMTPServer) = "smtp.gmail.com"
'Config(cdoSMTPServerPort) = 25
'Config(cdoSMTPAuthenticate) = cdoBasic
'Config(cdoSMTPUseSSL) = True
'Config(cdoSendUserName) = "alerte.intervention1@gmail.com "
'Config(cdoSendPassword) = "MONMOTDEPASSE" 'le mdp a ete modifié pour le forum
'Config.Fields.Update
'Mail.To = "XXX@XXXXXXX"
'Mail.from = Config(cdoSendUserName)
'Mail.Subject = "Subject from VBA"
'Mail.HTMLBody = "Nouvelle panne enregistrée par un technicien, au boulot!"
'Mail.Send
'MsgBox "Envoye"
End Sub
'Pour le bouton Modifier
Private Sub CommandButton2_Click()
Dim Ligne As Long
Dim I As Integer
If MsgBox("Confirmez-vous la modification de cette intervention ?", vbYesNo, "Demande deconfirmation de modification") = vbYes Then
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
For I = 1 To 12
If Me.Controls("TextBox" & I).Visible = True Then
Ws.Cells(Ligne, I + 2) = Me.Controls("TextBox" & I)
End If
Next I
End If
End Sub
'Pr bouton quitter
Private Sub CommandButton3_Click()
Unload Me
End Sub
Private Sub UserForm_Click()
End Sub |
Partager