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 111 112 113 114 115 116 117 118
| Private Sub ComboBox1_Change()
Dim MDP As String, Ligne As Long, Rep As Variant
MDP = InputBox("Entrer votre mot de passe")
'A partir d'ici, le code ne se déroule que lorsque mdp et nom sont corrects.
With Sheets("Liste")
If Application.VLookup(Me.ComboBox1.Text, .[C:D], 2, 0) = MDP Then
Ligne = Application.Match(Me.ComboBox1.Text, .[C:C], 0)
If .Cells(Ligne, 5).Value = "X" Then Sheets("Fiche d'intervention").Visible = True
If .Cells(Ligne, 6).Value = "X" Then Sheets("BDD").Visible = True
If .Cells(Ligne, 7).Value = "X" Then Sheets("Liste").Visible = True
End If
End With
Application.Visible = True
Application.WindowState = xlMaximized
Unload Me
End Sub
Private Sub CommandButton3_Click()
'Déclaration des variables
Dim MonOutlook As Object
Dim MonMessage As Object
Dim MyBench As String
Dim NumberOfIntervention As String
Dim Description_du_dysfonctionnement As String
'Condition pour l'envoie du mail
'Aller dans le module checking pour voir si tous se déroule correctement
If CheckingFormField.CheckingField = False Then
'Appel du module SaveInBDD1 ceci permet compléter la base de donée
SaveInBDD1
'Utilisation des variables sous format Non de la feuille plus cellule d'identification
MyBench = Sheets("Fiche d'intervention").Range("I10").Value
NumberOfIntervention = Sheets("Fiche d'intervention").Range("N1").Value
Description_du_dysfonctionnement = Sheets("Fiche d'intervention").Range("C19").Value
'Appel de la l'applicaion Outlook pour crée un mail
Set MonOutlook = CreateObject("Outlook.Application")
Set MonMessage = MonOutlook.CreateItem(0)
MonMessage.BodyFormat = 2
Corps = "<HTML><BODY>"
MonMessage.To = "<>"
MonMessage.CC = "<>"
MonMessage.Subject = "Demande d'intervention maintenance " & NumberOfIntervention
' Le corps du message est divisé en 2 lignes :
Corps = Corps & "Bonjour Christophe,"
' <p> = Touche ENTER
Corps = Corps & "<p>"
Corps = Corps & "<p> Voici la demande d'intervention pour le " & "<b>" & MyBench & "</b>" & " ainsi que le numéro d'intervention " & "<b>" & NumberOfIntervention & "</b></p>"
Corps = Corps & "<p> Voici le problème rencontré : " & "<b>" & Description_du_dysfonctionnement & "</b>"
Corps = Corps & "<p><a href=""H:\SERVICE\MAINTENANCE PREVENTIVE\Archivage fiche d'intervention maintenance\Fichier excel\Archivage fiche d'intervention maintenance 2016.xlsm"">lien vers l'interface maintenance</a></p>"
Corps = Corps & "</BODY></HTML>"
MonMessage.HTMLBody = Corps
MonMessage.Display
Set MonOutlook = Nothing
'Enlever les alertes
Application.DisplayAlerts = False
'Sauvegarder le fichier
ThisWorkbook.Save
'Fermer le fichier
ThisWorkbook.Close
Application.DisplayAlerts = True
'Rendre l'Aplication invisible
Application.Visible = True
End If
End Sub
Private Sub Systeme_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Condition dans l'userform si détection de texte alors je reste au blanc sinon je passe au bleu
If Systeme.Text = "" Then
Systeme.BackColor = RGB(128, 224, 253)
Else
Systeme.BackColor = vbWhite
End If
End Sub
Private Sub Compteur_Machine_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Condition dans l'userform si détection de texte alors je reste au blanc sinon je passe au bleu
If Compteur_machine.Text = "" Then
Compteur_machine.BackColor = RGB(128, 224, 253)
Else
Compteur_machine.BackColor = vbWhite
End If
End Sub
Private Sub Description_du_dysfonctionnement_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Condition dans l'userform si détection de texte alors je reste au blanc sinon je passe au blue
If Description_du_dysfonctionnement.Text = "" Then
Description_du_dysfonctionnement.BackColor = RGB(128, 224, 253)
Else
Description_du_dysfonctionnement.BackColor = vbWhite
End If
End Sub
Private Sub UserForm_Initialize()
Application.DisplayAlerts = False
'Récupération du nom de la personne qui utilise le fichier
Fiche.LblUserProfil.Caption = Environ("username")
'Afficher la date du jour
Fiche.LblDate.Caption = Format(Now, "dd/mm/yyyy")
With Sheets("Liste")
For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row 'Liste des bancs de la feuille "Liste"
Systeme.AddItem .Cells(i, 1)
Next
End With
'Liste des noms pour entrer dans la maintenance
ComboBox1.RowSource = ("Liste")
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Clic sur la croix rouge de l'interface et celle-ci disparait
Application.Visible = True
Application.WindowState = xlMaximized
End Sub |
Partager