.To = "moi@mail.fr; collègue_1@mail.fr; collègue_2@mail.fr; collègue_3@mail.fr"
For i = 0 To ListBox1.ListCount - 1 If i <> ListBox1.ListIndex Then toto = toto & ";" & ListBox1.List(i) End If Next toto = Mid(toto, 2) MsgBox toto
derlig = Worksheets("les_desti_possibles").Range("A" & Rows.Count).End(xlUp).Row ListBox1.RowSource = Worksheets("les_desti_possibles").Range("A1:A" & derlig).Address
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionje vais voir pour ouvrir un userform en premier avant d'aller plus loin
Private Sub CommandButton1_Click() UserForm1.Show End Sub
Private Sub CommandButton1_Click() For i = 0 To ListBox1.ListCount - 1 If i <> ListBox1.ListIndex Then liste_des_destis = liste_des_destis & ";" & ListBox1.List(i) End If Next liste_des_destis = Mid(liste_des_destis, 2) Dim fichier As String fichier = ActiveWorkbook.FullName Set ol = CreateObject("Outlook.Application") Set olmail = ol.CreateItem(olMailItem) Set ObjAttachement = olmail.Attachments Set MonOutlook = CreateObject("Outlook.Application") With olmail .To = liste_des_destis .Subject = "Fichier" .Body = "Voici la mise à jour du fichier." .Attachments.Add fichier .Send End With ' ......et le reste de ton code d'envoi '...... ' et n'oublie pas de terminer par des set ... = Nothing pour tous tes objetx ouverts par des setr Unload Me End Sub Private Sub CommandButton2_Click() CommandButton1.Visible = False CommandButton2.Visible = False End Sub Private Sub ListBox1_Click() If ListBox1.ListIndex <> -1 Then CommandButton1.Visible = True CommandButton2.Visible = True End If End Sub Private Sub UserForm_Activate() Dim ou As Worksheet Set ou = ActiveSheet CommandButton1.Visible = False CommandButton1.Caption = "Envoyer le fichier" CommandButton2.Visible = False CommandButton2.Caption = "Annuler le choix fait" With Label1 .Caption = "dans la liste ci-dessous, cliquez sur votre poropre addresse email" .AutoSize = True End With derlig = Worksheets("Feuille_destis").Range("A" & Rows.Count).End(xlUp).Row Worksheets("Feuille_destis").Activate ListBox1.RowSource = "A1:A" & derlig ou.Activate Set ou = Nothing If derlig < 2 Then Me.Hide MsgBox "au moins deux destinataires doivent figurer en colonne A de la feuille nommée Feuille_destis" Unload Me End If End Sub
Par contre, pour la 1ère, tu peux inclure dans le fichier Excel, une table de correspondance Nom utilisateur >>> adresse mail.