Excel >> PDF à intégrer dans un mail

nat54

XLDnaute Barbatruc
Bonjour,

Je pense qu'un nouveau fil s'impose après ce fil
https://www.excel-downloads.com/thr...eference-a-une-cellule-pour-le-chemin.112643/

Le contexte
Un onglets avec 20 graphiques, que je mets à jour grâce à pierrejean via une liste déroulante (je choisis un pôle dans cette liste, cela remplace dans données source automatiquement avec le nom de ce pôle comme onglet).

Mon nouveau "problème"
Via la barre d'outils pdfmaker, je peux en un clic transformer cet onglet en pdf qui se met en PJ d'un mail.
Cependant, étant donné que j'ai 22 pôles, cela m'oblige à faire 22 fois la manipulation.
En plus le nom du pdf est toujours le même, à savoir le nom du fichier excel or j'aimerais bien qu'il prenne le n° du pole
ex : 4000.pdf

Est-ce possible de créer en vba le même bouton que le pdfmaker
mais qui me fasse une boucle ?! sur tous les pôles

Le must serait - dans un 2nd temps - de rajouter un destinataire, un objet et un message dans le corps du mail.

Merci d'avance !!

Nat
 

kiki29

XLDnaute Barbatruc
Re : Excel >> PDF à intégrer dans un mail

Salut, si tu parles de PdfMaker tu as donc Acrobat Distiller
dans ce cas voir pour l'impression Excel vers PDF avec Acrobat Distiller - Forum des développeurs
et l'envoi https://www.excel-downloads.com/threads/choisir-un-fichier-pdf-et-lenvoyer-par-mail-en-vba.79294/
tout cela est à adapter par tes soins
En complément si Outlook voir
https://www.excel-downloads.com/thr...que-dune-plage-de-cellule-bien-definie.80897/
http://www.contextmagic.com/express-clickyes/
http://www.excelguru.ca/node/44
 
Dernière édition:

nat54

XLDnaute Barbatruc
Re : Excel >> PDF à intégrer dans un mail

je ne connais pas acrobat distiller...

là j'ai pris la première macro et justement ça plante là

Code:
[COLOR=#0000ff]Option[/COLOR] [COLOR=#0000ff]Explicit[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] sNomPortReseau [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR]
 
[COLOR=#0000ff]Sub[/COLOR] Tst_Adobe_PDF_03()
[COLOR=#0000ff]Dim[/COLOR] sNomFichierPS [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] sNomFichierPDF [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] sNomFichierLOG [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR]
[B][SIZE=3][COLOR=#0000ff]Dim[/COLOR] PDFDist [COLOR=#0000ff]As[/COLOR] PdfDistiller
[/SIZE][/B][COLOR=#0000ff]Dim[/COLOR] PrinterDefault [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR]
 
    [COLOR=#808080]'   Sur un PC "Personnel" : a priori choix libre du Nom[/COLOR]
    [COLOR=#808080]'   et de l'emplacement du fichier de sortie, on est logué en [/COLOR]
    [COLOR=#808080]'   Administrateur sur son PC[/COLOR]
    [COLOR=#808080]'[/COLOR]
    [COLOR=#808080]'   Sur un PC "Entreprise" :[/COLOR]
    [COLOR=#808080]'   Il faut être logué en Administrateur ou en[/COLOR]
    [COLOR=#808080]'   Avoir les droits pour utiliser Distiller[/COLOR]
    [COLOR=#808080]'   Les chemins PS PDF LOG devront être de la forme :[/COLOR]
    [COLOR=#808080]'       "C:\Documents and Settings\UserName\.....\....."[/COLOR]
 
    [COLOR=#808080]'   Si l'on a plusieurs imprimantes il faut :[/COLOR]
    [COLOR=#808080]'       Sélectionner l'imprimante virtuelle Adobe PDF tout en conservant[/COLOR]
    [COLOR=#808080]'           trace de l'imprimante utilisée par défaut[/COLOR]
    [COLOR=#808080]'   Le N° de port réseau NeXY varie suivant le PC sur lequel la macro tourne[/COLOR]
    
    PrinterDefault = Application.ActivePrinter
    [COLOR=#0000ff]If[/COLOR] Imprimante_AdobePDF [COLOR=#0000ff]Then[/COLOR]
        Application.ActivePrinter = sNomPortReseau
    [COLOR=#0000ff]Else[/COLOR]
        MsgBox [COLOR=#ff0000]"Pas d'imprimante Adobe PDF sur NeXY "[/COLOR], vbOKOnly+vbCritical, [COLOR=#ff0000]"Achtung"[/COLOR]
        [COLOR=#0000ff]Exit[/COLOR] [COLOR=#0000ff]Sub[/COLOR]
    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If[/COLOR]
   
    [COLOR=#808080]' Ici le cas d'un PC "Personnel"[/COLOR]
    sNomFichierPS = ThisWorkbook.Path & [COLOR=#ff0000]"\"[/COLOR] & [COLOR=#ff0000]"Essai_AdobbePDF.ps"[/COLOR]
    sNomFichierPDF = ThisWorkbook.Path & [COLOR=#ff0000]"\"[/COLOR] & [COLOR=#ff0000]"Essai_AdobbePDF.pdf"[/COLOR]
    sNomFichierLOG = ThisWorkbook.Path & [COLOR=#ff0000]"\"[/COLOR] & [COLOR=#ff0000]"Essai_AdobbePDF.log"[/COLOR]
 
    [COLOR=#808080]'   Impression d'une zone nommée[/COLOR]
    ActiveSheet.Range([COLOR=#ff0000]"Zone"[/COLOR]).PrintOut Copies:=[COLOR=#cc66cc]1[/COLOR], Preview:=[COLOR=#0000ff]False[/COLOR], _
                                       ActivePrinter:=sNomPortReseau , PrintToFile:=[COLOR=#0000ff]True[/COLOR], _
                                       Collate:=[COLOR=#0000ff]True[/COLOR], PrToFilename:=sNomFichierPS
 
    [COLOR=#0000ff]Set[/COLOR] PDFDist = [COLOR=#0000ff]New[/COLOR] PdfDistiller
    PDFDist.FileToPDF sNomFichierPS, sNomFichierPDF, [COLOR=#ff0000]""[/COLOR]
    [COLOR=#0000ff]Set[/COLOR] PDFDist = [COLOR=#0000ff]Nothing[/COLOR]
 
    Kill sNomFichierPS
    Kill sNomFichierLOG
 
    Application.ActivePrinter = PrinterDefault
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]
 
[COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Function[/COLOR] Imprimante_AdobePDF() [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Boolean[/COLOR]
[COLOR=#0000ff]Dim[/COLOR] i [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Long[/COLOR]
    [COLOR=#808080]' 11 imprimantes réseau[/COLOR]
    Imprimante_AdobePDF = [COLOR=#0000ff]False[/COLOR]
    [COLOR=#0000ff]For[/COLOR] i = [COLOR=#cc66cc]0[/COLOR] [COLOR=#0000ff]To[/COLOR] [COLOR=#cc66cc]10[/COLOR]
        [COLOR=#0000ff]If[/COLOR] i < [COLOR=#cc66cc]10[/COLOR] [COLOR=#0000ff]Then[/COLOR]
            sNomPortReseau = [COLOR=#ff0000]"Adobe PDF sur Ne0"[/COLOR] & i & [COLOR=#ff0000]":"[/COLOR]
        [COLOR=#0000ff]Else[/COLOR]
            sNomPortReseau = [COLOR=#ff0000]"Adobe PDF sur Ne"[/COLOR] & i & [COLOR=#ff0000]":"[/COLOR]
        [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If[/COLOR]
        [COLOR=#0000ff]On[/COLOR] [COLOR=#0000ff]Error[/COLOR] [COLOR=#0000ff]Resume[/COLOR] [COLOR=#0000ff]Next[/COLOR]
        Application.ActivePrinter = sNomPortReseau
        [COLOR=#0000ff]If[/COLOR] ActivePrinter = sNomPortReseau [COLOR=#0000ff]Then[/COLOR]
            Imprimante_AdobePDF = [COLOR=#0000ff]True[/COLOR]
            [COLOR=#0000ff]Exit[/COLOR] [COLOR=#0000ff]For[/COLOR]
        [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If[/COLOR]
    [COLOR=#0000ff]Next[/COLOR] i
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Function[/COLOR]
 

nat54

XLDnaute Barbatruc
Re : Excel >> PDF à intégrer dans un mail

Excel 2000
Acrobat Distiller 5.0
Adobe Acrobat 5.0 donc oui j'ai acrobat


ps : d'ailleurs va me falloir vraiment trouver comment exporter en pdf
car là, pour une autre demande, 20 onglets, 10 à transformer en pdf
or j'ai testé là (je vais ré-essayer) et ça ne me transforme que le 1er,
ca veut dire qu'on ne peut faire qu'un par un ?:eek:
 

nat54

XLDnaute Barbatruc
Re : Excel >> PDF à intégrer dans un mail

désolée mais je ne maitrise pas autant que vous le vba

et là je bloque car ca me met Pas d'imprimante Adobe PDF sur NeXY

Si l'on a plusieurs imprimantes il faut :
' Sélectionner l'imprimante virtuelle Adobe PDF tout en conservant
' trace de l'imprimante utilisée par défaut
' Le N° de port réseau NeXY varie suivant le PC sur lequel la macro tourne

PrinterDefault = Application.ActivePrinter
If Imprimante_AdobePDF Then
Application.ActivePrinter = sNomPortReseau
Else
MsgBox "Pas d'imprimante Adobe PDF sur NeXY
 

Discussions similaires

Statistiques des forums

Discussions
311 721
Messages
2 081 929
Membres
101 843
dernier inscrit
Thaly