Dim Chemin As String, Fich As String, Rep As String, CheminComplet As String
Chemin = ThisWorkbook.Path
Fich = CreateObject("Scripting.FileSystemObject").GetBaseName(ThisWorkbook.Name)
CheminComplet = Chemin & "\" & Fich & ".pdf"
Rep = Dir(Chemin & "\" & Fich & ".pdf")
If Rep = "" Then
réponse = MsgBox("Le fichier n'existe pas, création du fichier PDFCreator", vbYesNo)
If réponse = vbYes Then
Impression:
ChDir Chemin
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Rep, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False 'n'affiche pas le fichier PDF
Else
MsgBox "Sortie de la procédure"
Exit Sub
End If
Else
Réponse1 = MsgBox("le fichier existe voulez-vous le remplacer ?", vbYesNo)
If Réponse1 = vbYes Then
MsgBox "Remplacement du fichier existant"
GoTo Impression
Else
MsgBox "Sortie de la procédure"
End If
End If
' Envoyer
Dim olObj As Object
Set olObj = CreateObject("Outlook.Application")
'Ici ton code VBA impression feuille classeur Excel via Outlook.
Dim ol As New Outlook.Application
Dim olmail As MailItem
Dim CurrFile As String
Set ol = New Outlook.Application
'envoyer fichier PDF par courriel
Set olmail = ol.CreateItem(olMailItem)
With olmail
.To = "etienne.deschamps@wurth.fr" 'saisir l'adresse mail du commercial
.CC = "vincent.bouillon@wurth.fr" 'saisir l'adresse du chef des ventes
.Subject = ("Planning AKTISEA") 'ici le sujet
.Body = "Bonjour," & vbCrLf & vbCrLf & "Vous trouverez en pièce jointe le planning AKTISEA en format PDF ainsi que le lsiting d'entreprises que nous travaillons" & vbCrLf & vbCrLf & "Bonne journée!"
.Attachments.Add Chemin & "\" & Fich & ".pdf"
.Attachments.Add Chemin & "\" & Fich & ".xlsm" 'ici la pièce jointe
.Display '.Display /Send : Display correspond à l'affichage du message / Send demande un envoi direct
Set olObj = Nothing
End With
End Sub