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
| Private Sub CommandButton1_Click()
Dim derniere_ligne As Long
Dim fichier As Workbook
Dim onglet As Worksheet
Dim formulaire As Worksheet
Dim destinataire As Variant
'identifier login
Dim login As String
Dim ObjWshNw As Object
Set ObjWshNw = CreateObject("WScript.Network")
login = ObjWshNw.UserName
Set fichier = ActiveWorkbook
Set onglet = fichier.Worksheets("STATS")
Set formulaire = fichier.Worksheets("FORMULAIRE SAISIE")
derniere_ligne = onglet.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Copier les informations dans la dernière ligne du tableau
Sheets("FORMULAIRE SAISIE").Range("B2") = ComboBox1.Value 'Objet du message
Sheets("FORMULAIRE SAISIE").Range("C1") = ComboBox2.Value 'Gestionnaire destinataire
Sheets("FORMULAIRE SAISIE").Range("B3") = TextBox1.Value 'Société
Sheets("FORMULAIRE SAISIE").Range("B4") = TextBox4.Value 'Contact
Sheets("FORMULAIRE SAISIE").Range("B5") = TextBox2.Value 'Téléphone
Sheets("FORMULAIRE SAISIE").Range("B6") = TextBox3.Value 'Email
Sheets("FORMULAIRE SAISIE").Range("B7") = TextBox5.Value 'Message
Cells(derniere_ligne, "A") = Date
Cells(derniere_ligne, "B") = login 'Qui envoi le mail
Cells(derniere_ligne, "C") = ComboBox2.Value 'Gestionnaire
Cells(derniere_ligne, "D") = ComboBox1.Value 'Objet
Cells(derniere_ligne, "E") = TextBox1.Value 'Société
destinataire = formulaire.Range("B1").Value
'Message = [FORMULAIRE SAISIE'!B7]
ActiveCell.Hyperlinks.Add ActiveCell, "mailto: destinataire" & Email & "?subject= pas de sujet" & "?Body=Pas de lien???" & PropAdd, "", "", "Envoyer message"
Msg = "Envoyer le message?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then Exit Sub
If Ans = vbYes Then ActiveCell.Hyperlinks(1).Follow
'UserForm2.Show
'Call process_maj
End Sub
Private Sub UserForm_Initialize()
'Définition des variables
Dim info_liste() As Variant
Dim info_liste2() As Variant
Dim derniere_ligne As Long
Dim fichier As Workbook
Dim onglet As Worksheet
'identifier l'onglet Paramètres
Set fichier = ActiveWorkbook
Set onglet = fichier.Worksheets("PARAMETRES")
'---Je cache le tableur Excel au lancement du formulaire
Application.Visible = True
'---Objet du message---
derniere_ligne = onglet.Cells(Rows.Count, 3).End(xlUp).Row
info_liste = onglet.Range(onglet.Cells(1, 3), onglet.Cells(derniere_ligne, 3))
Me.ComboBox1.List = info_liste
'---Gestionnaire destinataire---
derniere_ligne = onglet.Cells(Rows.Count, 1).End(xlUp).Row
info_liste2 = onglet.Range(onglet.Cells(1, 1), onglet.Cells(derniere_ligne, 1))
Me.ComboBox2.List = info_liste2
End Sub |
Partager