laurent27530
XLDnaute Nouveau
Bonjour,
lorsque je joue ma macro plusieurs fois les pieces jointe s'addtionne.
avez vous une solution
Merci d'avance
lorsque je joue ma macro plusieurs fois les pieces jointe s'addtionne.
avez vous une solution
Merci d'avance
Code:
'variable
da = Now()
periode = Sheets("parametres").Cells(1, 2)
'fichier joints
rep1 = Sheets("PARAMETRES").Cells(22, 2)
source1 = Sheets("PARAMETRES").Cells(22, 3)
rep2 = Sheets("PARAMETRES").Cells(23, 2)
source2 = Sheets("PARAMETRES").Cells(23, 3)
rep3 = Sheets("PARAMETRES").Cells(24, 2)
source3 = Sheets("PARAMETRES").Cells(24, 3)
rep4 = Sheets("PARAMETRES").Cells(25, 2)
source4 = Sheets("PARAMETRES").Cells(25, 3)
'libelle du mail
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("B57")
liste2 = Sheets("Parametres").Range("B58")
liste3 = Sheets("Parametres").Range("B59")
Dim Adresse As String, Objet As String, Corps As String
dernligneA = Sheets("CF").Range("A65536").End(xlUp).Row + 1
'zone a récupéerr
Sheets("Ic").Select
ActiveSheet.Range("A1:N" & dernligneA).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
'.Introduction = "Bonjour, Veuillez trouver ci-joint le Rapport Hebdomadaire des POGS LOTB-LOTF : SCO_CHO_IH07_a_IH08_Vx et SCO_CHO_IH10_Vx"
.Item.To = liste1
.Item.CC = liste2
.Item.BCC = liste3
.Item.Subject = libelle
.Item.Attachments.Add source1
.Item.Attachments.Add source2
.Item.Attachments.Add source3
.Item.Attachments.Add source4
.Item.Send
End With
Sheets("TRAVAIL").Cells(26, 3) = "FAIT le " & da
' reinitialiser outlook
Set Attachments = Nothing
Set MailEnvelope = Nothing