abracadabraPDF › Forums › PDF – Général › Publipostage PDF avec Excel › Répondre à : Publipostage PDF avec Excel
24 janvier 2020 à 12:50
#62047

Maître des clés
j’ai trouvé un code
Je ne sais pas ce que c’est mais il sera certainement plus lisible ainsi :
Code:
Sub EnvoiMail() Dim OutObj As Object,
OutMail As Object Dim sPath As String,
sNomFic As String Dim sAdrMail As String,
strSujet As String,
strBody As String ‘ Chemin d’enregistrement des fichiers temporaire sPath = Environ(« temp ») & « »‘ Nom du fichier sNomFic = Format(Date,
« yyyymmdd ») & « .pdf » » Exporter le fichier actuel en PDF ThisDocument.ExportAsFixedFormat OutputFileName:=sPath & sNomFic,
ExportFormat:=wdExportFormatPDF,
_ OpenAfterExport:=False,
OptimizeFor:=wdExportOptimizeForPrint,
Range:=wdExportAllDocument,
_ Item:=wdExportDocumentContent,
IncludeDocProps:=True,
KeepIRM:=True,
CreateBookmarks:= _ wdExportCreateNoBookmarks,
DocStructureTags:=True,
BitmapMissingFonts:=True,
UseISO19005_1:=False » Création d’une instance Outlook pour envoyer un mailSet OutObj = CreateObject(« Outlook.Application ») Set OutMail = OutObj.CreateItem(0) ‘ Création de l’e-mail : Titre,
Corps du message,
destinataire sAdrMail = InputBox(« Adresse mail du destinataire »,
« ADRESSE MAIL »,
« @ ») ‘ Création du message strSujet = « CECI EST MON SUJET » strBody = « Bonjour, » & «
OutMail As Object Dim sPath As String,
sNomFic As String Dim sAdrMail As String,
strSujet As String,
strBody As String ‘ Chemin d’enregistrement des fichiers temporaire sPath = Environ(« temp ») & « »‘ Nom du fichier sNomFic = Format(Date,
« yyyymmdd ») & « .pdf » » Exporter le fichier actuel en PDF ThisDocument.ExportAsFixedFormat OutputFileName:=sPath & sNomFic,
ExportFormat:=wdExportFormatPDF,
_ OpenAfterExport:=False,
OptimizeFor:=wdExportOptimizeForPrint,
Range:=wdExportAllDocument,
_ Item:=wdExportDocumentContent,
IncludeDocProps:=True,
KeepIRM:=True,
CreateBookmarks:= _ wdExportCreateNoBookmarks,
DocStructureTags:=True,
BitmapMissingFonts:=True,
UseISO19005_1:=False » Création d’une instance Outlook pour envoyer un mailSet OutObj = CreateObject(« Outlook.Application ») Set OutMail = OutObj.CreateItem(0) ‘ Création de l’e-mail : Titre,
Corps du message,
destinataire sAdrMail = InputBox(« Adresse mail du destinataire »,
« ADRESSE MAIL »,
« @ ») ‘ Création du message strSujet = « CECI EST MON SUJET » strBody = « Bonjour, » & «
» _ & « Veuillez trouver en pièce jointe,
le document voulu. »‘ Préparation le mailWith OutMail ‘ Pour afficher la signature .Display ‘ Adresses mail .To = sAdrMail .cc = « »‘ Sujet de l’eMail .Subject = strSujet ‘ Corps du mail et signature .HTMLBody = strBody & «
» & .HTMLBody .Attachments.Add sPath & sNomFic EndWith’ Supprimer le fichier créé Kill sPath & sNomFic ‘ Effacer les objetsSet OutMail = NothingSet OutObj = NothingEndSub
:Smiley03: