bonjour à tous ,
j'ai un soucis sur une macro que j'ai piqué sur un bouquin excel 2007 (au boulot, j'ai excel 2003).
cette macro bugue au niveau de la varibale
Set ListeDest = ThisWorkbook.Worksheets("destinataire")
.
Et je n'y arrive pas à résoudre le problème .
Voici la macro entiere
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
| Sub EMAIL
'enregistrement du fichier()
'chemin pour l'enregistrement
ChDir "P:\Commun\Intranet PFC SLM\transport\REMORQUES VRAC\Archives\2009\septembre"
'nom du fichier
Dim MonFichier As String
MonFichier = Range("A4").Value & "-" & Format([A2].Value, "dddd-mm-yyyy")
ActiveWorkbook.SaveAs Filename:=MonFichier, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
Dim MonOutlook As New Outlook.Application
Dim MonMessage As Outlook.MailItem
Dim ListeDest As Worksheet
Set ListeDest = ThisWorkbook.Worksheets("destinataire")
Set MonMessage = MonOutlook.CreateItem(olMailItem)
With MonMessage
.Subject = "Fiche liaisons depart SLDM"
.Body = "Cordialement Madjid LARBI" & Chr(13) & "PFC Saint Laurent de Mure" & Chr(13) & "ZAC- Les Marches du Rhône-Ouest" & Chr(13) & "4, Boulevard de l'Europe" & Chr(13) & "69720 saint Laurent de Mure" & Chr(13) & "Tél : 04 72 48 36 47" & Chr(13) & "Fax : 04 72 48 36 88"""
.BodyFormat = olFormatHTML
ListeDest.Range("A2").Select
Do While ActiveCell.Value <> ""
.Recipients.Add (ActiveCell.Value)
ActiveCell.Offset(1, 0).Select
Loop
.Attachements.Add ActiveWorkbook.Path & "P:\Commun\Intranet PFC SLM\transport\REMORQUES VRAC\Archives\2009\septembre" & ActiveWorkbook.Name
.Send
End With
MonOutlook.Quit
Set MonOutlook = Nothing
Set MonMessage = Nothing
Set ListeDest = Nothing
End Sub |
Partager