Lone-wolf
XLDnaute Barbatruc
Bonjour à tous,
Ce code permet d'ouvrir par défaut la fenêtre Ouvrir un fichier et l'envoyer en pièce jointe dans Outlook.
Private Sub CommandButton5_Click()
Dim olapp As New Outlook.Application
Dim Msg As MailItem
Dim cell As Range
Dim strcc As String
ChDrive "D"
Dir ("D:\Dossiers Excel\Formulaires\Recherche Contacts\")
Set olapp = New Outlook.Application
Set Msg = olapp.CreateItem(olMailItem)
For Each cell In ThisWorkbook.Sheets(1).Range("F3:F102")
strcc = strcc & cell.Value & ";"
Next
Msg.To = TextBox6.Value
Msg.cc = ""
Msg.BCC = strcc
Msg.Subject = ""
Msg.Body = ""
Msg.Attachments.Add Application.GetOpenFilename()
Msg.Display
End Sub
J'aimerais maintenant fermer la fenêtre avec le bouton Annuler, dans le cas de non envois du fichier.
Comment on écrit le code dans ce cas?
Merci de votre aide
Ce code permet d'ouvrir par défaut la fenêtre Ouvrir un fichier et l'envoyer en pièce jointe dans Outlook.
Private Sub CommandButton5_Click()
Dim olapp As New Outlook.Application
Dim Msg As MailItem
Dim cell As Range
Dim strcc As String
ChDrive "D"
Dir ("D:\Dossiers Excel\Formulaires\Recherche Contacts\")
Set olapp = New Outlook.Application
Set Msg = olapp.CreateItem(olMailItem)
For Each cell In ThisWorkbook.Sheets(1).Range("F3:F102")
strcc = strcc & cell.Value & ";"
Next
Msg.To = TextBox6.Value
Msg.cc = ""
Msg.BCC = strcc
Msg.Subject = ""
Msg.Body = ""
Msg.Attachments.Add Application.GetOpenFilename()
Msg.Display
End Sub
J'aimerais maintenant fermer la fenêtre avec le bouton Annuler, dans le cas de non envois du fichier.
Comment on écrit le code dans ce cas?
Merci de votre aide