Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. Dim docOBJ As Variant
  2. Dim loopCounter As Integer
  3. Dim numberOfPages As Integer
  4. Debug.Print collectionOfAddresses.Count & " addresses accepted"
  5.  
  6. For Each localAddress In collectionOfAddresses
  7. Dim localDocument As Acrobat.CAcroPDDoc
  8. Set localDocument = CreateObject("AcroExch.PDDoc")
  9. collectionOfDocs.Add localDocument
  10. Dim currentCollectionPos As Integer
  11. currentCollectionPos = collectionOfDocs.Count
  12.  
  13. Debug.Print "Opening " & localAddress
  14. collectionOfDocs(currentCollectionPos).Open (localAddress)
  15.  
  16. Next localAddress
  17. Debug.Print ("Created localDocObjects " & collectionOfDocs.Count)
  18.  
  19. Debug.Print collectionOfDocs(1).GetFileName() & " has " & collectionOfDocs(1).GetNumPages() & " pages"
  20. For loopCounter = 2 To collectionOfAddresses.Count
  21. numberOfPages = collectionOfDocs(1).GetNumPages()
  22.  
  23. If (collectionOfDocs(1).InsertPages(0, collectionOfDocs(loopCounter), 0, 1, True)) Then MsgBox "Error"
  24. Debug.Print "loopCounter: " & loopCounter
  25. Debug.Print "numberOfPages: " & numberOfPages - 1
  26. Debug.Print "Appending: " & collectionOfDocs(loopCounter).GetFileName()
  27. Debug.Print "Number of pages appending: " & collectionOfDocs(loopCounter).GetNumPages()
  28.  
  29.  
  30. Debug.Print collectionOfDocs(loopCounter).GetFileName() & " has " & collectionOfDocs(loopCounter).GetNumPages() & " pages"
  31. Next loopCounter
  32. Dim newBinderPath As String
  33. newBinderPath = ActiveWorkbook.Path & "Binder.pdf"
  34.  
  35. If collectionOfDocs(1).Save(PDSaveFull, newBinderPath) = False Then MsgBox "Cannot save the modified document"
  36.  
  37. End Sub
  38. Sub testMergePDFList()
  39. Dim addressCollection As New Collection
  40. addressCollection.Add "Y:CompletionsEngineers Toolbox2017 Platform2017 platform Standard Well Program TXT.pdf"
  41. addressCollection.Add "Y:CompletionsEngineers Toolbox2017 PlatformKropp 1H 15 Stage Pump Schedule.pdf"
  42.  
  43.  
  44. Call mergePDFList(addressCollection)
  45.  
  46. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement