IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

pdf avec PDFCréator


Sujet :

Macros et VBA Excel

  1. #1
    Membre averti Avatar de BRUNO71
    Homme Profil pro
    Retraité
    Inscrit en
    Janvier 2007
    Messages
    502
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Saône et Loire (Bourgogne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 502
    Points : 319
    Points
    319
    Par défaut pdf avec PDFCréator
    Bonjour,
    Je reviens vers un sujet déjà abordé.
    J'ai copié un bout de code et j'aimerai à partir d'un UserForm déclencher cette macro....
    Et adjoindre deux feuilles sur un seul PDF...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    Dim ImpPDF As Object
    Dim NomPDF As String
    Dim RepertoirePDF As String
    Dim ClientPDF As String
    Dim CheminPDF As String
    Dim SheetPDF As String
     
    CheminPDF = "C:\MesDocuments\FichierPDF\"
    ClientPDF = Sheets("Feuil1").Range("A1").Value
    NomPDF = ClientPDF & ".pdf"
    RepertoirePDF = NomPDF
    SheetPDF = Sheets("Feuil2") & Sheets("Feuil3")
     
    If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
    Set ImpPDF = CreateObject("PDFCreator.clsPDFCreator")
    With ImpPDF
    If .cStart("/NoProcessingAtStartup") = False Then
    MsgBox "Impossibilité d'initialiser PDFCréator !", vbCritical + vbOKOnly, "PDFCreator"
    Exit Sub
    End If
    .cOption("UseAutosave") = 1
    .cOption("UseAutosaveDirectory") = 1
    .cOption("AutosaveDirectory") = CheminPDF
    .cOption("AutosaveFilename") = RepertoirePDF
    .cOption("AutosaveFormat") = 0
    .cClearCache
    End With
    ActiveSheetPDF.PrintOut copies:=1, ActivePrinter:="PDFCreator"
    Do Until ImpPDF.cCountOfPrintjobs = 1
    DoEvents
    Loop
    ImpPDF.cPrinterStop = False
    Do Until ImpPDF.cCountOfPrintjobs = 0
    DoEvents
    Loop
    ImpPDF.cClose
    Set ImpPDF = Nothing
    Je déclare SheetPDF, ( 2 feuilles ) Est-ce possible ?
    Cette macro fonctionne bien avec une seule feuille.
    Est-ce l'UserForm qui fait que ça Bug ??

    Bien cordialement

  2. #2
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

    Informations professionnelles :
    Activité : Chercheur de bonheur
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Bonjour,

    je pense qu'il y a un problème dans ton code car tu imprime l'activesheet mais rien ne dit que tes 2 feuilles on été activées.

    Fais plutot comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Dim ImpPDF As Object
    Dim NomPDF As String
    Dim RepertoirePDF As String
    Dim ClientPDF As String
    Dim CheminPDF As String
    Dim SheetPDF As String
     
    CheminPDF = "C:\MesDocuments\FichierPDF\"
    ClientPDF = Sheets("Feuil1").Range("A1").Value
    NomPDF = ClientPDF & ".pdf"
    RepertoirePDF = NomPDF
    'SheetPDF = Sheets("Feuil2") & Sheets("Feuil3")
    Sheets(Array("Feuil2", "Feuil3")).Select
     
    If IsEmpty(selection.UsedRange) Then Exit Sub
    Set ImpPDF = CreateObject("PDFCreator.clsPDFCreator")
    With ImpPDF
    If .cStart("/NoProcessingAtStartup") = False Then
    MsgBox "Impossibilité d'initialiser PDFCréator !", vbCritical + vbOKOnly, "PDFCreator"
    Exit Sub
    End If
    .cOption("UseAutosave") = 1
    .cOption("UseAutosaveDirectory") = 1
    .cOption("AutosaveDirectory") = CheminPDF
    .cOption("AutosaveFilename") = RepertoirePDF
    .cOption("AutosaveFormat") = 0
    .cClearCache
    End With
    ActiveWindow.SelectedSheets.PrintOut copies:=1, ActivePrinter:="PDFCreator"
    Do Until ImpPDF.cCountOfPrintjobs = 1
    DoEvents
    Loop
    ImpPDF.cPrinterStop = False
    Do Until ImpPDF.cCountOfPrintjobs = 0
    DoEvents
    Loop
    ImpPDF.cClose
    Set ImpPDF = Nothing
    (\ _ /) Cordialement G@dz
    (='.'=)

    (")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.

  3. #3
    Membre averti Avatar de BRUNO71
    Homme Profil pro
    Retraité
    Inscrit en
    Janvier 2007
    Messages
    502
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Saône et Loire (Bourgogne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 502
    Points : 319
    Points
    319
    Par défaut Pdf avec PDF Créator
    Bonjour,

    MErci beaucoup pour ton aide.

    Bien cordialement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VB]Générer un fichier Postscript à partir d'un pdf avec VB
    Par Vince dans le forum VB 6 et antérieur
    Réponses: 7
    Dernier message: 20/09/2005, 19h00
  2. [VB6] Créer un .PDF avec VB ?
    Par Vince dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 21/07/2005, 14h27
  3. OpenOffice - storeToUrl en PDF avec Delphi
    Par Thomad dans le forum API, COM et SDKs
    Réponses: 3
    Dernier message: 31/05/2005, 13h38
  4. [CR][.Net] Exportation PDF avec Crystal Report
    Par SoaB dans le forum SAP Crystal Reports
    Réponses: 2
    Dernier message: 11/05/2005, 13h25
  5. Réponses: 2
    Dernier message: 15/04/2005, 15h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo