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

Contribuez Discussion :

Excel / Word / PDF avec Adobe Acrobat Pro et PDFCreator 1.7.3 (obsolète)


Sujet :

Contribuez

  1. #21
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Visualisation d'un fichier PDF dans une UserForm
    Il faut avoir installé Acrobat Reader ( gratuit )

    Créer une UserForm
    dans UserForm placer le code suivant
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    Option Explicit
     
    Private Sub UserForm_Initialize()
        With UserForm1
            .Height = 600
            .Width = 600
        End With
    End Sub
    Dans un module Standard placer le code
    puis affecter un bouton à la procédure SelFichierPDF
    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
    40
    41
    42
    43
    Option Explicit
     
    Private Sub LoadPDF(ByVal sNomFichier As String, iNumPage As Long)
    Dim oPDF As Object
     
        Set oPDF = UserForm1.Controls.Add("AcroPDF.PDF.1", "DisplayPDF")
     
        With UserForm1.Controls("DisplayPDF")
            .Height = UserForm1.Height - 20
            .Width = UserForm1.Width - 5
            .Visible = True
        End With
     
        With oPDF
            '   Nom fichier
            .src = sNomFichier
            .setShowScrollbars True
            '   Barre d'outils
            .SetShowToolbar True
            '   none bookmarks thumbs
            .setPageMode "bookmarks"
            '   DontCare SinglePage OneColumn TwoColumnLeft TwoColumnRight
            .setLayoutMode "SinglePage"
            '  page affichée
            .setCurrentPage iNumPage
            '   Fit FitH FitV FitB FitBH FitB
            .setView "Fit"
            '   Zoom
            .setZoom 58
        End With
     
        UserForm1.Show
        Set oPDF = Nothing
    End Sub
     
    Sub SelFichierPDF()
    Dim Fichier As Variant
        ChDir ThisWorkbook.Path
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf")
        If Fichier = False Then Exit Sub
        DoEvents
        LoadPDF Fichier, 1
    End Sub
      3  0

  2. #22
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    PDFCreator Lecture des métadonnées d'un fichier PDF
    Affecter un bouton à SelFichier

    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
    Option Explicit
     
    Private Sub Lecture_MetaDatas(ByVal sNomFichier As String)
    Dim Pdf As Object, sStr As String
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
     
    '    Public Function GetMetadata( _
    '        sourceFilename As String, _
    '        key As String _
    '    ) As String
     
        sStr = "Application : " & Pdf.GetMetadata(sNomFichier, "Creator") & vbCrLf
        sStr = sStr & "Auteur : " & Pdf.GetMetadata(sNomFichier, "Author") & vbCrLf
        sStr = sStr & "Sujet : " & Pdf.GetMetadata(sNomFichier, "Subject") & vbCrLf
        sStr = sStr & "Mots-Clés : " & Pdf.GetMetadata(sNomFichier, "Keywords") & vbCrLf
        sStr = sStr & "Titre : " & Pdf.GetMetadata(sNomFichier, "Title") & vbCrLf
        sStr = sStr & "Outil de conversion PDF : " & Pdf.GetMetadata(sNomFichier, "Producer") & vbCrLf
        sStr = sStr & "Date Création : " & Pdf.GetMetadata(sNomFichier, "CreationDate") & vbCrLf
        sStr = sStr & "Date Modification : " & Pdf.GetMetadata(sNomFichier, "ModDate") & vbCrLf
     
        MsgBox sStr
        Set Pdf = Nothing
    End Sub
     
    Sub SelFichier()
    Dim Fichier As Variant
        ChDir ThisWorkbook.Path
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf")
        If Fichier = False Then Exit Sub
        DoEvents
        Lecture_MetaDatas Fichier
    End Sub
      3  0

  3. #23
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    PDFCreator Extraction de pages d'un catalogue PDF et fusion de ces pages dans un seul fichier Pdf
    Dans un classeur Excel
    Créer sur une feuille en A2...Axy la liste des pages à extraire
    Affecter un bouton à la procédure SelFichier
    Dans ce code ShParam est le CodeName de la feuille : voir pour explications CodeName
    Dans un module standard insérer le code suivant

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    Option Explicit
     
    Dim sOut As String
    Dim sNomFichierFusion As String
    Dim bFlag As Boolean
    Dim Fichiers()
    Dim Cpt As Long
     
    Private Sub ExtractionFusionPDF(ByVal SNomFichier As String)
    Dim LastRow As Long, i As Long
     
        ShParam.Range("A2:A" & Rows.Count).Interior.ColorIndex = xlNone
     
        Application.ScreenUpdating = False
        LastRow = ShParam.Range("A" & Rows.Count).End(xlUp).Row
     
        bFlag = False
        For i = 2 To LastRow
            ExtractionPDF SNomFichier, ShParam.Range("A" & i)
            If bFlag Then
                ShParam.Range("A" & i).Interior.ColorIndex = 36
                Exit For
            End If
        Next i
     
        Fusion
     
        For i = LBound(Fichiers) To UBound(Fichiers)
            Kill Fichiers(i)
        Next i
     
        Application.ScreenUpdating = True
    End Sub
     
    Private Sub ExtractionPDF(sNom As String, iNum As Long)
    Dim Pdf As Object
    Dim iNbPages As Long
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
        iNbPages = Pdf.NumberOfPages(sNom)
        If iNum > iNbPages Then
            bFlag = True
            Set Pdf = Nothing
            Exit Sub
        End If
     
        sOut = ThisWorkbook.Path & "\" & "Catalogue_" & Cpt + 1 & ".pdf"
        Pdf.CopyPDFFile sNom, sOut, iNum, iNum
     
        ReDim Preserve Fichiers(Cpt)
        Fichiers(Cpt) = sOut
        Cpt = Cpt + 1
        Set Pdf = Nothing
    End Sub
     
    Private Sub Fusion()
    Dim Pdf As Object
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
        Pdf.MergePDFFiles_2 Fichiers, sNomFichierFusion, True
        Set Pdf = Nothing
    End Sub
     
    Sub SelFichier()
    Dim Fichier As Variant
        ChDir ThisWorkbook.Path
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf", Title:="Sélection PDF")
        If Fichier = False Then Exit Sub
        DoEvents
        Cpt = 0
        sNomFichierFusion = ThisWorkbook.Path & "\" & "Fusion Cat.pdf"
        ExtractionFusionPDF Fichier
    End Sub
      4  0

  4. #24
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    PDFCreator Extraction de pages d'un catalogue PDF et insertion de ces pages dans un classeur Excel
    Dans un classeur Excel
    Créer sur une feuille en A2...Axy la liste des pages à extraire
    Affecter un bouton à la procédure SelFichier
    Dans ce code ShParam est le CodeName de la feuille : voir pour explications CodeName
    Dans un module standard insérer le code suivant

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    Private Declare Function QueryPerformanceCounter Lib "kernel32" (x As Currency) As Boolean
    Private Declare Function QueryPerformanceFrequency Lib "kernel32" (x As Currency) As Boolean
     
    Option Explicit
     
    Dim Dep As Currency, Fin As Currency, Freq As Currency
    Dim sOut As String
    Dim bFlag As Boolean
     
    Private Sub DeleteALL()
    Dim Ws As Worksheet
        For Each Ws In ThisWorkbook.Worksheets
            If Ws.Name <> ShParam.Name Then
                Application.DisplayAlerts = False
                Ws.Delete
                Application.DisplayAlerts = True
            End If
        Next Ws
        Application.StatusBar = ""
    End Sub
     
    Private Sub ExtractionPDF(sNom As String, iNumPage As Long)
    Dim Pdf As Object
    Dim iNbPages As Long
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
        iNbPages = Pdf.NumberOfPages(sNom)
        If iNumPage > iNbPages Then
            bFlag = True
            Set Pdf = Nothing
            Exit Sub
        End If
        Pdf.CopyPDFFile sNom, sOut, iNumPage, iNumPage
        Set Pdf = Nothing
    End Sub
     
    Private Sub InsertionPDF(ByVal SNomFichier As String)
    Dim LastRow As Long, i As Long
     
        ShParam.Range("A2:A" & Rows.Count).Interior.ColorIndex = xlNone
     
        DeleteALL
        Application.ScreenUpdating = False
        LastRow = ShParam.Range("A" & Rows.Count).End(xlUp).Row
     
        sOut = ThisWorkbook.Path & "\" & "Extraction.pdf"
        bFlag = False
        For i = 2 To LastRow
            ExtractionPDF SNomFichier, ShParam.Range("A" & i)
            If bFlag Then
                ShParam.Range("A" & i).Interior.ColorIndex = 36
                Exit For
            End If
            Worksheets.Add
            With ActiveSheet
                .Move after:=Worksheets(Worksheets.Count)
                .Range("A1").Select
                .OLEObjects.Add Filename:=sOut
                ActiveWindow.DisplayGridlines = False
                ActiveSheet.Tab.ColorIndex = 19
            End With
            Application.StatusBar = "Insertion : " & i - 1 & " / " & LastRow - 1
        Next i
     
        ShParam.Activate
        Kill sOut
        Application.ScreenUpdating = True
    End Sub
     
    Sub SelFichier()
    Dim Fichier As Variant
    Dim s As Double
        ChDir ThisWorkbook.Path
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf", Title:="Sélection PDF")
        If Fichier = False Then Exit Sub
        QueryPerformanceCounter Dep
        DoEvents
        Application.StatusBar = ""
        InsertionPDF Fichier
        QueryPerformanceCounter Fin
        QueryPerformanceFrequency Freq
        s = (Fin - Dep) / Freq
        Application.StatusBar = Application.StatusBar & " : " & Format(s, "0.00 s")
    End Sub
      4  0

  5. #25
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    PDFCreator Extraction de pages d'un catalogue PDF et insertion de ces PDF en réduction sur une feuille Excel

    Dans un classeur Excel
    Créer sur une feuille en A2...Axy la liste des pages à extraire
    En B2 : une plage nommée NbPagesH qui détermine le nombre de PDF disposés horizontalement
    Affecter un bouton à la procédure SelFichier
    Dans ce code ShParam est le CodeName de la feuille : voir pour explications CodeName
    Il en est de même pour ShRecap
    Dans un module standard insérer le code suivant
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    Private Declare Function QueryPerformanceCounter Lib "kernel32" (x As Currency) As Boolean
    Private Declare Function QueryPerformanceFrequency Lib "kernel32" (x As Currency) As Boolean
     
    Option Explicit
     
    Dim Dep As Currency, Fin As Currency, Freq As Currency
    Dim sOut As String
    Dim bFlag As Boolean
     
    Private Sub DeleteAllSheets()
    Dim Ws As Worksheet
        For Each Ws In ThisWorkbook.Worksheets
            If Ws.Name <> ShParam.Name And Ws.Name <> ShRecap.Name Then
                Application.DisplayAlerts = False
                Ws.Delete
                Application.DisplayAlerts = True
            End If
        Next Ws
        Application.StatusBar = ""
    End Sub
     
    Private Sub DelOleRecapIns()
    Dim oOle As OLEObject
        For Each oOle In Worksheets(ShRecap.Name).OLEObjects
            ShRecap.Shapes(oOle.Name).Delete
        Next oOle
    End Sub
     
    Private Sub ExtractionPDF(sNom As String, iNumPage As Long)
    Dim Pdf As Object
    Dim iNbPages As Long
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
        iNbPages = Pdf.NumberOfPages(sNom)
        If iNumPage > iNbPages Then
            bFlag = True
            Set Pdf = Nothing
            Exit Sub
        End If
        Pdf.CopyPDFFile sNom, sOut, iNumPage, iNumPage
        Set Pdf = Nothing
    End Sub
     
    Private Sub InsertionPDF(ByVal SNomFichier As String)
    Dim LastRow As Long, i As Long
     
        ShParam.Range("A2:A" & Rows.Count).Interior.ColorIndex = xlNone
     
        DeleteAllSheets
        DelOleRecapIns
     
        Application.ScreenUpdating = False
        LastRow = ShParam.Range("A" & Rows.Count).End(xlUp).Row
     
        sOut = ThisWorkbook.Path & "\" & "Extraction.pdf"
        bFlag = False
        For i = 2 To LastRow
            ExtractionPDF SNomFichier, ShParam.Range("A" & i)
            If bFlag Then
                ShParam.Range("A" & i).Interior.ColorIndex = 36
                Exit For
            End If
     
            With ShRecap
                .Activate
                .Range("A1").Select
                .OLEObjects.Add Filename:=sOut
            End With
            Application.StatusBar = "Insertion : " & i - 1 & " / " & LastRow - 1
        Next i
     
        ShParam.Activate
        Kill sOut
        Application.ScreenUpdating = True
    End Sub
     
    Private Sub PosShapesIns()
    Dim oOle As OLEObject
    Dim i As Long
    Dim L As Double, W As Double
    Dim T As Double, H As Double, Pas As Double
    Dim Tablo() As String, sNomOle As String
    Dim Nb As Long, Coeff As Double
     
        i = 0
        For Each oOle In Worksheets(ShRecap.Name).OLEObjects
            sNomOle = ShRecap.Shapes(oOle.Name).Name
            ReDim Preserve Tablo(i)
            Tablo(i) = sNomOle
            i = i + 1
        Next oOle
     
        If i = 0 Then Exit Sub
     
        With ShRecap.Shapes(Tablo(0))
            W = .Width
            H = .Height
            Coeff = H / W
        End With
     
        W = Application.CentimetersToPoints(6)
        H = W * Coeff    ' Si A4 Coeff=1.414
        Pas = Application.CentimetersToPoints(0.25)
     
        For i = LBound(Tablo) To UBound(Tablo)
            With ShRecap.Shapes(Tablo(i))
                .Width = W
                .Height = H
            End With
        Next i
     
        Nb = ShParam.Range("NbPagesH")
        For i = LBound(Tablo) To UBound(Tablo)
            L = (i Mod Nb) * (W + Pas)
            T = (i \ Nb) * (H + Pas)
            With ShRecap.Shapes(Tablo(i))
                .Left = L
                .Top = T
            End With
        Next i
     
        With ShRecap
            .Activate
            .Range("A1").Select
        End With
    End Sub
     
    Sub SelFichier()
    Dim Fichier As Variant
    Dim s As Double
        ChDir ThisWorkbook.Path
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf", Title:="Sélection PDF pour Insertion Excel")
        If Fichier = False Then Exit Sub
        DoEvents
        QueryPerformanceCounter Dep
        Application.StatusBar = ""
     
        InsertionPDF Fichier
        PosShapesIns
     
        QueryPerformanceCounter Fin: QueryPerformanceFrequency Freq
        s = (Fin - Dep) / Freq
        Application.StatusBar = Application.StatusBar & " : " & Format(s, "0.00 s")
    End Sub
      4  0

  6. #26
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Rotation d'une Page
    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
    Option Explicit
     
    Sub Tst_Rotation()
    Dim PDDoc As Object   
    Dim PDPage As Object    
    Dim sFichier As String, sNomSave As String
     
        Set PDDoc = CreateObject("AcroExch.PDDoc")
     
        sFichier = ThisWorkbook.Path & "\" & "Test.pdf"
        sNomSave = ThisWorkbook.Path & "\" & "Test_Rot.pdf"
     
        PDDoc.Open sFichier
        '   La 1ere Page est la 0
        '   ici sélection 2eme Page
        Set PDPage = PDDoc.AcquirePage(1)
     
        '   4 Valeurs de Rotation permises : 0° 90° 180° 270°
     
        PDPage.SetRotate 90
     
        With PDDoc
            .Save 1, sNomSave
            .Close
        End With
     
        Set PDPage = Nothing
        Set PDDoc = Nothing
     
    End Sub
      5  0

  7. #27
    Expert éminent
    Avatar de Didier Gonard
    Homme Profil pro
    Formateur Office et développeur VBA en freelance
    Inscrit en
    Février 2008
    Messages
    2 805
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Formateur Office et développeur VBA en freelance

    Informations forums :
    Inscription : Février 2008
    Messages : 2 805
    Points : 6 696
    Points
    6 696
    Par défaut
    Salut Philippe,

    Excellent boulot

    Peut-être devrais-tu changer le titre de ton Post initial, vu que tu as largement, pour le plus grand bien, débordé maintenant le strict cadre d'Acrobat Distilller

    cordialement,

    Didier
    Didier Gonard

    Dernier tutoriel :
    Le VBA qu'est ce que c'est ?
    Tutoriels : Voir la liste de mes tutoriels Excel & VBA et mon site pro sur ma Page DVP
    Cours et tutoriels pour apprendre Excel
    N'oubliez pas de mettre : ..quand c'est le cas !
      2  0

  8. #28
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    PDFCreator Suppression des pages vides d'un fichier 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
    Option Explicit
     
    Sub SelFichier()
    Dim Fichier As Variant
        ChDir ThisWorkbook.Path 
        Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf")
        If Fichier = False Then Exit Sub
        DoEvents
        Supprimer_PagesVides (Fichier)
    End Sub
     
    Private Sub Supprimer_PagesVides(sNomFichier As String)
    Dim Pdf As Object
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
     
        'Public Function RemoveEmptyPagesFromPDFFile( _
         '    sourceFilename As String, _
         '    destinationFilename As String _
         ') As Integer
     
        Pdf.RemoveEmptyPagesFromPDFFile sNomFichier, "Output.pdf"
     
        Set Pdf = Nothing
    End Sub
    PDFCreator Suppression de la page X d'un fichier 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
    Option Explicit
     
    Sub Tst_Supprimer_PageX()
    Dim Pdf As Object
     
        Set Pdf = CreateObject("pdfforge.pdf.pdf")
        Pdf.CreatePDFTestDocument "input.pdf", 10, "Essai", True
     
        'Public Function RemovePageFromPDFFile( _
         '    sourceFilename As String, _
         '    destinationFilename As String, _
         '    pageNumber As Integer _
         ') As Integer
     
        Pdf.RemovePageFromPDFFile "Input.pdf", "Output.pdf", 1
     
        Set Pdf = Nothing
        Kill "Input.pdf"
    End Sub
      5  0

  9. #29
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Insertion d'un arrière plan Pdf dans un Document 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
    39
    40
    41
    42
    43
    44
    Option Explicit
     
    Sub Tst_PDFBackground()
    Dim PDDoc As Object 
    Dim PDArPlan As Object 
    Dim Modele As Object 
    Dim iNbPages As Long
    Dim sDocPdf As String
    Dim sBackGround As String
    Dim sOutPdf As String
     
        sDocPdf = ThisWorkbook.Path & "\" & "catalogue.pdf"
        sBackGround = ThisWorkbook.Path & "\" & "Test.pdf"
        sOutPdf = ThisWorkbook.Path  & "\" & "Out BackGround.pdf"
     
        Set PDDoc= CreateObject("AcroExch.PDDoc")
        PDDoc.Open sDocPdf
        DoEvents
     
        Set PDArPlan = CreateObject("AcroExch.PDDoc")
        PDArPlan.Open sBackGround
        DoEvents
     
        '   Ajout Ar Plan dans le doc de Base
        PDDoc.InsertPages PDDoc.GetNumPages - 1, PDArPlan, 0, 1, 0
     
        '   Créer un Template à partir du doc d'Ar Plan qui vient d'être inséré
        Set Modele = PDDoc.GetJSObject.CreateTemplate("background", PDDoc.GetNumPages - 1)
     
        '   Duplication sur toutes les pages du Doc Pdf du Modele
        For iNbPages = 0 To PDDoc.GetNumPages - 2
            Modele.Spawn iNbPages, True, True
        Next iNbPages
     
        '   Suppression derniere page utilisée comme Ar Plan
        PDDoc.DeletePages PDDoc.GetNumPages - 1, PDDoc.GetNumPages - 1
     
        PDDoc.Save 1, sOutPdf
        PDDoc.Close
        Set PDDoc= Nothing
     
        PDArPlan.Close
        Set PDArPlan = Nothing
    End Sub
      4  0

  10. #30
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Insertion de Données Excel dans les Signets de N° de Page
    Autrement dit ces signets, qui permettent la navigation de page en page, sont créés à la volée et leur intitulé provient d'une feuille Excel.
    Cette feuille dont le CodeName est ShParam : la plage A1:Axy est le contenu à insérer
    Créer un bouton sur ShParam et l'affecter à Tst_Signets

    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
    40
    41
    42
    43
    44
    Option Explicit
     
    Sub Tst_Signets()
    Dim sIn As String
    Dim sOut As String
        sIn = ThisWorkbook.Path & "\" & "Test.pdf"
        sOut = ThisWorkbook.Path & "\" & "Test Bookmarks.pdf"
        AjoutDonneesExcel_SignetNumPage sIn, sOut
    End Sub
     
    Private Sub AjoutDonneesExcel_SignetNumPage(sNomFichier As String, sSortie As String)
    Dim AcroApp As Object
    Dim AVDoc As Object
    Dim PDDoc As Object
    Dim JSO As Object
    Dim iPageDep As Long, iPageFin As Long
    Dim sStr As String
    Dim i As Long
     
        Set AcroApp = CreateObject("AcroExch.App")
        Set AVDoc = CreateObject("AcroExch.AVDoc")
     
        If AVDoc.Open(sNomFichier, sNomFichier) Then
            Set PDDoc = AVDoc.GetPDDoc
            Set JSO = PDDoc.GetJSObject
     
            iPageDep = 0
            iPageFin = PDDoc.GetNumPages - 1
     
            For i = iPageDep To iPageFin
                sStr = ShParam.Range("A" & i + 1)
                JSO.BookmarkRoot.CreateChild sStr, "this.pageNum=" & i, i
            Next i
     
            PDDoc.Save 1, sSortie
     
            Set JSO = Nothing
            Set PDDoc = Nothing
        End If
     
        AcroApp.CloseAllDocs
        Set AVDoc = Nothing
        AcroApp.Exit
    End Sub
      7  0

  11. #31
    Rédacteur
    Avatar de Philippe Tulliez
    Homme Profil pro
    Formateur, développeur et consultant Excel, Access, Word et VBA
    Inscrit en
    Janvier 2010
    Messages
    12 755
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Formateur, développeur et consultant Excel, Access, Word et VBA

    Informations forums :
    Inscription : Janvier 2010
    Messages : 12 755
    Points : 28 606
    Points
    28 606
    Billets dans le blog
    53
    Par défaut
    Bonjour Philippe,
    Citation Envoyé par kiki29 Voir le message
    Insertion de Données Excel dans les Signets de N° de Page
    Dans une feuille dont le CodeName est ShParam : la plage A1:Axy est le contenu à insérer
    Créer un bouton sur ShParam et l'affecter à Tst_Signets
    Génial ce code qui tombe à pic pour moi.
    Pas plus tard qu'hier, j'étais confronté à ce problème d'insérer un signet pour documenter un classeur Excel publié en PDF.
    Philippe Tulliez
    Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément. (Nicolas Boileau)
    Lorsque vous avez la réponse à votre question, n'oubliez pas de cliquer sur et si celle-ci est pertinente pensez à voter
    Mes tutoriels : Utilisation de l'assistant « Insertion de fonction », Les filtres avancés ou élaborés dans Excel
    Mon dernier billet : Utilisation de la fonction Dir en VBA pour vérifier l'existence d'un fichier
      2  0

  12. #32
    Membre éclairé
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2007
    Messages
    615
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2007
    Messages : 615
    Points : 841
    Points
    841
    Par défaut
    Bonjour
    Et grand merci à tous ces bouts de codes.
    Personnellement, je ne développe pas sur office, je m'en sers pour ensuite le traduire.
    C'est ce que j'ai fait avec ces bouts de codes, qui s'intègrent parfaitement dans Windev.
    Est ce que tu sais où on peut trouver les valeurs des constantes utilisées par les fonctions Adobe ?
    Merci d'avance
    Gancau
      1  0

  13. #33
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Conversion Image Tif Bmp Gif Jpg en 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
    Option Explicit
     
    Sub Tst_Image()
    Dim sIn As String
    Dim sOut As String
        sIn = ThisWorkbook.Path & "\"  & "Snoopy.tif"
        sOut = ThisWorkbook.Path & "\" & "Test Image.pdf"
        Image2PDF sIn, sOut
    End Sub
     
    Private Sub Image2PDF(sIn As String, sOut As String)
    Dim AcroApp As Object
    Dim AVDoc As Object
    Dim PDDoc As Object
     
        Set AcroApp = CreateObject("AcroExch.App")
        Set AVDoc = CreateObject("AcroExch.AVDoc")
     
        If AVDoc.Open(sIn, sIn) Then
            Set PDDoc = AVDoc.GetPDDoc
            With PDDoc
                .SetInfo "Title", "Essai Image"
                .SetInfo "Author", "Kiki"
                .SetInfo "Subject", "Images en PDF"
                .SetInfo "Keywords", "Tiff Bmp Gif Jpg Pdf"
                .Save 1, sOut
                .Close
            End With
        End If
     
        AVDoc.Close True
        AcroApp.Exit
     
        Set PDDoc = Nothing
        Set AVDoc = Nothing
        Set AcroApp = Nothing
    End Sub
      5  0

  14. #34
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Utilisation de scripts JavaScript
    Il faut placer ces scripts *.js dans le dossier JavaScripts d'Adobe Acrobat
    c'est à dire : C:\Program Files\Adobe\Acrobat x.x\Acrobat\Javascripts

    Un exemple placé dans le dossier Javascripts qui renvoie le nombre de signets.
    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
    function CountBookmarks(bkm, nLevel)
    {
        var count = 0;
        if (bkm.children != null)
        {
            count = bkm.children.length;
            for (var i = 0; i < bkm.children.length; i++)
            {
                 count += CountBookmarks(bkm.children[i], nLevel + 1);
            }
        }
        return count;
    }
     
    function CountAllBookmarks()
    {
        var n = CountBookmarks(this.bookmarkRoot, 0);
        return n;
    }
    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
    Option Explicit
     
    Sub Tst_JScript()
    Dim AcroApp As Object
    Dim PDDoc As Object
    Dim JSO As Object
    Dim sFichier As String
     
        Set AcroApp = CreateObject("AcroExch.App")
        Set PDDoc = CreateObject("AcroExch.PDDoc")
     
        sFichier = ThisWorkbook.Path & "\" & "Test bmk.pdf"
        If PDDoc.Open(sFichier) Then
            Set JSO = PDDoc.GetJSObject
            Debug.Print JSO.CountAllBookmarks()
            PDDoc.Close
            Set JSO = Nothing
        End If
     
        Set PDDoc = Nothing
        Set AcroApp = Nothing
    End Sub
      3  0

  15. #35
    Membre éclairé
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2007
    Messages
    615
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2007
    Messages : 615
    Points : 841
    Points
    841
    Par défaut
    Bonjour Kiki,
    J'utilise toujours ton code qui marche nickel.
    Evidement les utilisateurs ne sont pas entièrement satisfaits
    grace à ton post N° 2, je sauvegarde leur pdf en jpeg avec l'option
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    saveas(nouveaunom,"com.adobe.acrobat.jpeg")
    Il se trouve que mes jpeg sont trop gros, je voudrais alors leur appliquer des paramètres du style :
    * niveau de gris : JPEG(Qualité moyenne)
    * couleur : JPEG(Qualité moyenne)
    * résolution : 59,06 pixels/cm
    cela me divise par 10 la taille des fichiers jpeg générés.
    Je ne trouve pas dans le sdk de fonction à ce sujet, je ne sais même pas comment ces options se nomment en anglais
    Si tu as une piste, ce serait avec plaisir
    Merci d'avance
    Gancau
      1  0

  16. #36
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Salut, je crains que l'accès à ces paramètres ne soit pas possible, en tout cas je n'ai pas trouvé. Il faut passer par PhotoShop ou autre.

    A la génération du PDF il faudrait déjà appliquer un des réglages prédéfinis, situé chez moi dans C:\Program Files\Adobe\Acrobat 6.0\Distillr\Settings\ et nommé Smallest File Size.joboptions qui réduit la taille des Pdf.

    PS : dans Acrobat quand tu enregistres en JPEG tu as un bouton Options et accès à qqs paramètres. Tu peux également créer un nouveau réglage via Distiller et son menu configuration.
      3  0

  17. #37
    Membre éclairé
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2007
    Messages
    615
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2007
    Messages : 615
    Points : 841
    Points
    841
    Par défaut
    En tout cas merci d'avoir répondu.
    Je ne trouvais effectivement rien à ce sujet.
    Je cherche une autre solution.
    Bonne continuation
    Gancau
      1  0

  18. #38
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Un exemple prenant en compte un "setting" d'Acrobat pour la génération d'un 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
    Option Explicit
     
    Sub Tst_Adobe_Setting()
    Dim sNomFichierPS As String
    Dim sNomFichierPDF As String
    Dim sNomFichierLOG As String
    Dim PDFDist As Object
    Dim sSetting As String
     
        sNomFichierPS = ThisWorkbook.Path & "\" & "Essai_Setting.ps"
        sNomFichierPDF = ThisWorkbook.Path & "\" & "Essai_Setting.pdf"
        sNomFichierLOG = ThisWorkbook.Path & "\" & "Essai_Setting.log"
     
        ActiveSheet.Range("Zone").PrintOut Copies:=1, Preview:=False, _
                                           ActivePrinter:="Adobe PDF", PrintToFile:=True, _
                                           Collate:=True, PrToFilename:=sNomFichierPS
     
        sSetting = "C:\Program Files\Adobe\Acrobat 6.0\Distillr\Settings\Smallest File Size.joboptions"
     
        Set PDFDist = CreateObject("PdfDistiller.PdfDistiller")
        PDFDist.FileToPDF sNomFichierPS, sNomFichierPDF, sSetting
        Set PDFDist = Nothing
     
        Kill sNomFichierPS
        Kill sNomFichierLOG
     
    End Sub
      3  0

  19. #39
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Fusion des fichiers PDF d'un dossier
    Version généraliste de ce post

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    Option Explicit
     
    Sub Tst_Fusion()
    Dim sDossierPDF As String
    Dim sDossierOut As String
    Dim sFichierFusion As String
     
        sDossierPDF = ThisWorkbook.Path & "\"
        sDossierOut = ThisWorkbook.Path & "\" & "Test" & "\"
        sFichierFusion = "Fusion.pdf"
     
        FusionPDFs sDossierPDF, sDossierOut, sFichierFusion
    End Sub
     
    Private Sub FusionPDFs(sPdfDir As String, _
                                   sPdfOutDir As String, _
                                   sFichierOut As String)
    Dim bFirst As Boolean
    Dim oPDDoc As Object
    Dim oTempPDDoc As Object
    Dim oFolder As Object
    Dim TabloFichiers() As String
    Dim oFile As Object
    Dim FSO As Object
    Dim i As Long
     
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set oFolder = FSO.GetFolder(sPdfDir)
        bFirst = True
     
        If oFolder.Files.Count = 0 Then Exit Sub
     
        ReDim TabloFichiers(1 To oFolder.Files.Count)
     
        i = 0
        For Each oFile In oFolder.Files
            i = i + 1
            TabloFichiers(i) = oFile.Name
        Next oFile
     
        '   Placer ici une éventuelle
        '   routine de tri des fichiers de TabloFichiers
     
        For i = 1 To UBound(TabloFichiers)
            If LCase$(Right$(TabloFichiers(i), 4)) = ".pdf" Then
                If bFirst Then
                    bFirst = False
                    Set oPDDoc = CreateObject("AcroExch.PDDoc")
                    oPDDoc.Open sPdfDir & TabloFichiers(i)
                Else
                    Set oTempPDDoc = CreateObject("AcroExch.PDDoc")
                    oTempPDDoc.Open sPdfDir & "\" & TabloFichiers(i)
     
                   '  Paramètres :
                   '   1 Page du document en cours après laquelle l'insertion sera faite. La 1ere page est 0.
                   '   2 Document contenant les pages à insérer.
                   '   3 La 1ere page à être insérée dans le document oPDDoc
                   '       à partir du Document oTempPDDoc contenant ces pages à insérer.
                   '   4 Le nombre de pages à insérer.
                   '   5 Si nombre > 0 les bookmarks sont copiés, si 0 ils ne le sont pas.
     
                    oPDDoc.InsertPages oPDDoc.GetNumPages - 1, oTempPDDoc, 0, oTempPDDoc.GetNumPages, 1
                    oTempPDDoc.Close
                End If
            End If
        Next i
     
        With oPDDoc
            .Save 1, sPdfOutDir & "\" & sFichierOut
            .Close
        End With
     
        Set oFolder = Nothing
        Set oFile = Nothing
        Set FSO = Nothing
        Set oPDDoc = Nothing
        Set oTempPDDoc = Nothing
    End Sub
      4  0

  20. #40
    Expert éminent sénior
    Avatar de kiki29
    Homme Profil pro
    ex Observeur CGG / Analyste prog.
    Inscrit en
    Juin 2006
    Messages
    6 132
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : ex Observeur CGG / Analyste prog.

    Informations forums :
    Inscription : Juin 2006
    Messages : 6 132
    Points : 11 274
    Points
    11 274
    Par défaut
    Fusion des fichiers PDF d'un dossier à partir d'une liste Excel
    La liste des fichiers à fusionner est dans la plage A1:Axy de Feuil1.
    Cela permet de placer les fichiers dans un ordre quelconque qui sera celui de l'insertion pour générer le fichier PDF de fusion.

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    Option Explicit
     
    Sub Tst_Fusion()
    Dim sDossierPDF As String
    Dim sDossierOut As String
    Dim sFichierFusion As String
     
        sDossierPDF = ThisWorkbook.Path & "\"
        sDossierOut = ThisWorkbook.Path & "\" & "Test" & "\"
        sFichierFusion = "Fusion.pdf"
     
        FusionPDFs sDossierPDF, sDossierOut, sFichierFusion
    End Sub
     
    Private Sub FusionPDFs(sPdfDir As String, _
                           sPdfOutDir As String, _
                           sFichierOut As String)
    Dim bFirst As Boolean
    Dim oPDDoc As Object
    Dim oTempPDDoc As Object
    Dim LastRow As Long
    Dim i As Long
    Dim sFichier As String
     
        bFirst = True
        LastRow = Feuil1.Range("A" & Rows.Count).End(xlUp).Row
     
        For i = 1 To LastRow
            sFichier = Feuil1.Range("A" & i)
            If bFirst Then
                bFirst = False
                Set oPDDoc = CreateObject("AcroExch.PDDoc")
                oPDDoc.Open sPdfDir & sFichier
            Else
                Set oTempPDDoc = CreateObject("AcroExch.PDDoc")
                oTempPDDoc.Open sPdfDir & "\" & sFichier
                oPDDoc.InsertPages oPDDoc.GetNumPages - 1, oTempPDDoc, 0, oTempPDDoc.GetNumPages, 1
                oTempPDDoc.Close
            End If
        Next i
     
        With oPDDoc
            .Save 1, sPdfOutDir & "\" & sFichierOut
            .Close
        End With
     
        Set oPDDoc = Nothing
        Set oTempPDDoc = Nothing
    End Sub
      6  0

Discussions similaires

  1. resultat sur un fichier excel,word,pdf
    Par harakatyouness dans le forum C#
    Réponses: 3
    Dernier message: 08/08/2007, 16h45
  2. convertir en pdf avec adobe VBA
    Par sophie.baron dans le forum Général VBA
    Réponses: 1
    Dernier message: 26/03/2007, 14h49
  3. Problème avec adobe acrobat reader
    Par Rabie de OLEP dans le forum Windows XP
    Réponses: 4
    Dernier message: 24/03/2007, 20h50
  4. Problème avec Adobe acrobat reader
    Par castelm dans le forum Autres Logiciels
    Réponses: 4
    Dernier message: 08/03/2007, 21h19
  5. Impression .PDF avec adobe
    Par popo68 dans le forum Access
    Réponses: 2
    Dernier message: 26/02/2007, 12h19

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