Créer un pdf d'une feuille excel puis envoi par mail directement
crabouille78
Messages postés
8
Statut
Membre
-
crabouille78 Messages postés 8 Statut Membre -
crabouille78 Messages postés 8 Statut Membre -
Bonjour,
j'ai besoin de créer d'une feuille excel un fichier pdf et que celui s'envoi en pièce jointe par mail.
voici ce que j'ai déjà préparé mais le souci c'est que le fichier pdf reste ouvert et donc la pièce jointe ne s'insère pas.
Merci de votre future aide.
Sub ToPdf()
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
NomExcel = ThisWorkbook.Name
NomPdf = Left(NomExcel, Len(NomExcel) - 4) & ".pdf"
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = ThisWorkbook.Path
.cOption("AutosaveFilename") = NomPdf
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveWorkbook.Worksheets("DDE de PRIX").PrintOut copies:=1, ActivePrinter:="Imprimante pdf"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
.cClose
End With
Set pdfjob = Nothing
'Envoi du fichier PDF final par email
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
With myItem
.Subject = "Notre demande de Prix"
.To = ActiveWorkbook.Worksheets("DDE de PRIX").Range("G14").Value
'fichier en cours d'utilisation envoyé en attaché:
myItem.Attachments.Add Fichier
myItem.Display
End With
End Sub
j'ai besoin de créer d'une feuille excel un fichier pdf et que celui s'envoi en pièce jointe par mail.
voici ce que j'ai déjà préparé mais le souci c'est que le fichier pdf reste ouvert et donc la pièce jointe ne s'insère pas.
Merci de votre future aide.
Sub ToPdf()
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
NomExcel = ThisWorkbook.Name
NomPdf = Left(NomExcel, Len(NomExcel) - 4) & ".pdf"
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = ThisWorkbook.Path
.cOption("AutosaveFilename") = NomPdf
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveWorkbook.Worksheets("DDE de PRIX").PrintOut copies:=1, ActivePrinter:="Imprimante pdf"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
.cClose
End With
Set pdfjob = Nothing
'Envoi du fichier PDF final par email
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
With myItem
.Subject = "Notre demande de Prix"
.To = ActiveWorkbook.Worksheets("DDE de PRIX").Range("G14").Value
'fichier en cours d'utilisation envoyé en attaché:
myItem.Attachments.Add Fichier
myItem.Display
End With
End Sub
A voir également:
- Créer un pdf d'une feuille excel puis envoi par mail directement
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Comment créer un groupe whatsapp - Guide
- Créer un compte google - Guide
- Créer une liste déroulante excel - Guide
- Créer un lien pour partager des photos - Guide