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 41 42
   | Sub SendWithAtt() 
 
Dim Rep As Integer 
i = [B7].Value 
Rep = MsgBox("Voulez-vous envoyer le bon de commande chez " & i, vbYesNo + vbQuestion, "mDF XLpages.com") 
If Rep = vbYes Then 
' ici le traitement si réponse positive 
' ... 
Dim fichier As String 
fichier = "D:\Moi\Desktop\zik\" & [E5].Value & "_" & [B3].Value 
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fichier, _ 
Quality:=xlQualityStandard, IncludeDocProperties:=True, _ 
IgnorePrintAreas:=False, OpenAfterPublish:=False 
 
 
Dim olApp As Outlook.Application 
Dim olMail As MailItem 
Dim CurFile As String 
Set olApp = New Outlook.Application 
Set olMail = olApp.CreateItem(olMailItem) 
 
CurFile = ThisWorkbook.Path & "\" & "MaFeuille.Pdf" 
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurFile, _ 
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _ 
OpenAfterPublish:=False 
With olMail 
.To = [L9].Value 
.Subject = [E5].Value & "_" & [B3].Value 
.Body = "Vous trouverez ci-joint le fichier PDF ..." 
.Attachments.Add CurFile 
 
.Display '.Send 
End With 
Else 
' ici le traitement si réponse négative 
' ... 
End If 
 
' Effacer les variables objets 
Set olMail = Nothing 
Set olApp = Nothing 
End Sub | 
Partager