Private Sub CommandButton1_Click()
Call envoi_mail
End Sub
Sub envoi_mail()
répertoireAppli = ActiveWorkbook.Path
Sheets("TDGM").Copy
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs répertoireAppli & "\Absences Mosson-Hôp Fac.xls"
ActiveWindow.Close
'--- Envoi par mail
Dim olapp As Outlook.Application
Sheets("destinataires").Select
Range("A11").Select
Do While Not IsEmpty(ActiveCell)
Dim msg As MailItem
Set olapp = New Outlook.Application
Set msg = olapp.CreateItem(olMailItem)
msg.To = ActiveCell.Value
msg.Subject = Range("A2").Value
msg.Body = Range("A5").Value & Chr(13) & Chr(13) & Range("A8").Value & Chr(13) & Chr(13)
msg.Attachments.Add Source:=répertoireAppli & "\Absences Mosson-Hôp Fac.xls"
msg.Send
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Private Sub Workbook_Open()
Sheets("Destinataires").Visible = False
End Sub
Sub envoi_mail()
Application.ScreenUpdating = False
Sheets("Destinataires").Visible = True
.....
.....
Sheets("Destinataires").Visible = False
Application.ScreenUpdating = True
Sub envoi_mail()
Application.ScreenUpdating = False
Sheets("Destinataires").Visible = True
.....
.....
Sheets("Destinataires").Visible = False
Application.ScreenUpdating = True
Sub envoi_mail()
Application.ScreenUpdating = False
Sheets("Destinataires").Visible = True
.....
.....
....
ActiveCell.Offset(1, 0).Select
Loop
Sheets("Destinataires").Visible = False
Application.ScreenUpdating = True
End Sub
imaginez le gars en face qui n'a pas de patience (il prend la machine et pette un plomb...).
If FichierXls.Saved = True Then
Fichier = FichierXls.FullName
FichierXls.Close
Sheets("destinataires").Select
-----------------
Function SendMailCDO(Sender As String, Receiver As String, _
Subject As String, BodyText As String, _
Optional BodyHTML As String, _
Optional Cc As String, _
Optional Bcc As String, _
Optional Attach1 As String)
Dim Cdo_Message As New CDO.Message
-------------------
Quel appel dois je faire?Private Sub CommandButton1_Click()
Call envoi_mail
End Sub
Erreur de compilation
Type défini par l'utilisateur non défini
--------------------------
, "Fichier à Attacher introuvable !"
End If
End If
[B][COLOR="Red"] .Send[/COLOR][/B] -------------------------> ici bloque, affiche message
End With
-------------------------