Duplication des piece jointes a chaque envoi VBA EXCEL
Bonjour,
- J'ai créer un script qui fonctionne en revanche si je lance deux fois il cumule les peces jointes.
Premier envoi j'ai 1 piece , au deuxieme 2, au troisieme 3, .......
sous office 2007
Code:
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
| 'variable
da = Now()
'fichier joints
source1 = Sheets("parametres").Cells(14, 3) ' fichier source CF2-CF7
rep1 = Sheets("parametres").Cells(14, 2) 'rep source CF2-CF7
fi1 = rep1 & source1 'fichier a attacher CF2-CF7
'libelle du mail
periode = Sheets("parametres").Cells(1, 2)
A = Application.CountIf(Sheets("EX").Range("H:H"), "En dessous du seuil")
If A > 0 Then libelle = "Indicateurs CF au " & periode & " : Rouge ET Vert"
If A = 0 Then libelle = "Indicateurs CF au " & periode & " : Vert"
'destinataires
liste1 = Sheets("Parametres").Range("B47")
liste2 = Sheets("Parametres").Range("B48")
liste3 = Sheets("Parametres").Range("B49")
Dim Adresse As String, Objet As String, Corps As String
dernligneA = Sheets("CF").Range("A65536").End(xlUp).Row + 1
Sheets("CF").Select
ActiveSheet.Range("A1:G" & dernligneA).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Item.To = liste1
.Item.CC = liste2
.Item.Subject = libelle
.Item.Attachments.Add fi1
.Item.Send
End With
Sheets("TRAVAIL").Cells(26, 3) = "FAIT le " & da
' reinitialiser outlook
Set MailEnvelope = Nothing |