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
| On Error GoTo GestionErreur
Dim Sourcewb As Workbook, Destwb As Workbook, Temp As String, strErreurEnvoiMail As String
Set Sourcewb = ActiveWorkbook
ActiveSheet.Copy
Set Destwb = ActiveWorkbook
Temp = ThisWorkbook.Path & Application.PathSeparator & "Nom " & Format(Date, "ddmmyyyy") & ".xls"
strErreurEnvoiMail = "Impossible d'envoyer la feuille automatiquement."
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
Destwb.SaveAs Filename:=Temp, FileFormat:=xlExcel8
'------ Envoi du mail avec la méthode sendmail.
strSujetMail = "Bla Bla Bla"
strDestinataires(0) = "toto@domaine.com": strDestinataires(1) = "titi@domaine.com"
Destwb.SendMail strDestinataires, strSujetMail, False
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
Destwb.Close savechanges:=False
Kill Temp
Exit Sub
GestionErreur: MsgBox strErreurEnvoiMail
End Sub |
Partager