XL 2010 Lien hypertext dans PDF

etpisculrien

XLDnaute Occasionnel
Bonjour à tous,

J'ai un "petit" problème et je me suis dit que la communauté pourrait p-e m'aider...
Je vous explique:
J'ai compilé 2 ou 3 codes que j'ai récupéré pour fusionner différents pdf par VBA
Le problème que j'ai est que ça bug sur la ligne "m = UBound(BookmarkRoot.Children) + 1" et je soupçonne que ce soit un problème de bibliothèque. En effet, il semble qu'il y ait besoin d'activer "adobe acrobat 6.0 type library" mais je ne la vois pas dans les références de VBA.
L'autre possibilité est que mon code soit mauvais (je copie en dessous pour que vous puissiez voir)

Si quelqu'un pouvait m'aider, ce serait super cool (j'ai plus qu'une poignée de cheveux sur la tête!)

Merci d'avance

Ah oui, je tourne sur Excel 2010, Adobe Acrobat XI pro, Windows 7 pro

Sub Fusion_PDFs3()
'Application.DisplayAlerts = False
Dim oPDDoc1 As Object
Dim oPDDoc As Object
Dim Num As Long
Dim Chemin As String, Fichier As String
Dim insertSuccess As Boolean
Dim m As Long, p As Long
Dim JSO As Object, BookmarkRoot As Object
Dim Children As Variant

Nombre = 0
n = 2
While Sheets("param").Cells(n, 1) <> Empty
Nombre = Nombre + 1
n = n + 1
Wend
Nombre = Nombre


Sheets("Page de garde").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="" & ThisWorkbook.Path & "\" & "Page de garde.pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

Set oPDDoc1 = CreateObject("AcroExch.PDDoc")
oPDDoc1.Open (ThisWorkbook.Path & "\" & "Page de garde.pdf")

PageInser = 0

For NbDoc = 2 To Nombre + 1
Chemin = "" & Sheets("param").Cells(NbDoc, 6) & "\"
Fichier = Dir(Chemin & "*.pdf")

Do While Len(Fichier) > 0
Set oPDDoc = CreateObject("AcroExch.PDDoc")
oPDDoc.Open (Chemin & Fichier)
Num = oPDDoc.GetNumPages()
insertSuccess = oPDDoc1.InsertPages(PageInser, oPDDoc, 0, Num, 0)

If insertSuccess Then
Set JSO = oPDDoc1.GetJSObject
Set BookmarkRoot = JSO.BookmarkRoot
m = UBound(BookmarkRoot.Children) + 1
BookmarkRoot.createChild "Bookmark " & m & " Page " & Num + 1, "this.pageNum=" & Num, m
End If


oPDDoc.Close
PageInser = PageInser + 1
Fichier = Dir
Loop
Next NbDoc
oPDDoc1.Save 1, ThisWorkbook.Path & "\" & "Fusion.pdf"
' oPDDoc1.Close

' My.Computer.FileSystem.DeleteFile (ThisWorkbook.Path & "\" & "Page de garde.pdf")
Set oPDDoc = Nothing
Set oPDDoc1 = Nothing
Kill (ThisWorkbook.Path & "\" & "Page de garde.pdf")
Application.DisplayAlerts = True
End Sub
 

Discussions similaires

Réponses
2
Affichages
240

Statistiques des forums

Discussions
312 228
Messages
2 086 421
Membres
103 205
dernier inscrit
zch