Option Explicit
Dim Adresse As String
Dim Nom, Prenom As String
Private Sub BT_Adresse_Click()
If Me.TB_Nom = Empty Or Me.TB_Prenom = Empty Then
MsgBox ("Il manque des informations!"), vbExclamation
Exit Sub
End If
Nom = Me.TB_Nom.Value
Prenom = Me.TB_Prenom.Value
Adresse = Prenom + "." & Nom + "@safrangroup.com"
Feuil7.Unprotect "$sagem01"
Userform2.Label4.Caption = Adresse
Sheets("Table_BDD").[U1].Value = Adresse
Feuil7.Protect "$sagem01"
End Sub
Private Sub Userform_QueryClose(Cancel As Integer, closeMode As Integer)
Cancel = closeMode = 0
End Sub
Private Sub UserForm2_Initialize()
Feuil7.Unprotect "$sagem01"
Dim Mat As Integer
Dim Ws2 As Worksheet
Set Ws2 = Sheets("Table_BDD")
With Me.CBB_Commande
For Mat = 1 To Ws2.Range("U" & Rows.Count).End(xlUp).Row
.AddItem Ws2.Range("U" & Mat)
Next
End With
Me.Userform2.Label4.Caption = Sheets("Table_BDD").[U1].Value
End Sub
Private Sub CB_OK_Click()
Dim Erreur As String
Dim Un_Mail, Corps_Mail As Variant
If CBB_Commande = Empty Then
Erreur = MsgBox("Il manque le nom de la fourniture à commander!", vbExclamation, "Erreur de commande")
Exit Sub
End If
If TB_Quantite = Empty Then
Erreur = MsgBox("Il manque la quantité à commander!", vbExclamation, "Erreur de quantité")
Exit Sub
End If
Corps_Mail = "Bonjour Emilie," & Chr(10) & "Pour la salle Covid19, peux-tu stp, commander:" & Chr(10) & "- " _
& Me.TB_Quantite & " " & Me.CBB_Commande & Chr(10) & Chr(10) & "Merci"
Set Un_Mail = CreateObject("outlook.application")
With Un_Mail.CreateItem(0)
.Subject = "Demande d'approvisionnement"
.To = Sheets("Table_BDD").[U1]
.Body = Corps_Mail
.Display
End With
End Sub
Private Sub CB_KO_Click()
Unload Userform2
UserForm1.Show
End Sub