Consulting

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 49

Thread: Need code to merge PDF files in a folder using adobe acrobat X

  1. #21
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location
    I am using Excel professional (Office professional). I am using the free Adobe Reader edition. I am sorry but I do not have Acrobat X Pro.

  2. #22
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    To validate the referenced objects (early binding) in VBE choose Debug - Compile VBAProject.
    Debugger will highlight incorrect objects in the code if exist.

  3. #23
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location
    Debugger compiles just fine. But again while executing the same error "Cannot create ActiveX object."

  4. #24
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    Quote Originally Posted by kishlaya View Post
    I am using Excel professional (Office professional). I am using the free Adobe Reader edition. I am sorry but I do not have Acrobat X Pro.
    Adobe Reader Version XI should work, hope that its reinstalling will help.
    I'd also temporary check the code in the new created workbook without reference to Microsoft Access Object Library shown in your attachment of post #17

  5. #25
    VBAX Regular
    Joined
    Dec 2008
    Posts
    86
    Location
    Ah! I am on a computer from work. As far as I know, I cannot install Adobe Reader XI . Thanks for your help!

  6. #26
    VBAX Newbie
    Joined
    Jul 2014
    Posts
    4
    Location
    I also learned that if you have Acrobat pro, you can highlight the files and right click to combine supported files in Acrobat and it'll merge them for you. Found out about this after working with getting the macro to work.

  7. #27
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    Not sure the code works well with previous versions of Acrobat Reader.
    Such error usually indicates the Acrobat's DLL needs to be re-registered, and yea - it's the job for IT guys.
    Good luck and thanks for testing the code!

  8. #28
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    There are several PDF programs one can use to merge and splice/split PDF files. PDFSam is one. Here is a split example. http://www.vbaexpress.com/forum/show...d-instructions

    PDFSam also has a GUI method to do it as well. Before I got Adobe Pro, it used one of those methods.

    I also wrote a vb.net file to accept command line parameters to do it using the iTextSharp.dll routines.

    There are several other 3rd party PDF programs to can accept command line parameters if you are seeking that kind of solution.

  9. #29
    VBAX Newbie
    Joined
    Oct 2014
    Posts
    2
    Location
    hey I have the abobe pro XI, Im getting a Compile error at Call MergePDFS(MyPath, Myfiles, DestFile), is there a different way to call it? I updated my references and using the follwing code.

    '
    ' adobeme Macro
    '
    '

    Const DestFile As String = "MergedFile.pdf" ' <-- change to suit

    Dim MyPath As String, MyFiles As String
    Dim a() As String, i As Long, f As String

    ' Choose the folder or just replace that part by: MyPath = Range("E3")
    With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = "H:\TEST PDF\"
    .AllowMultiSelect = False
    If .Show = False Then Exit Sub
    MyPath = "H:\TEST PDF"
    DoEvents
    End With

    ' Populate the array a() by PDF file names
    If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
    ReDim a(1 To 2 ^ 14)
    f = Dir(MyPath & "*.pdf")
    While Len(f)
    If StrComp(f, DestFile, vbTextCompare) Then
    i = i + 1
    a(i) = f
    End If
    f = Dir()
    Wend

    ' Merge PDFs
    If i Then
    ReDim Preserve a(1 To i)
    MyFiles = Join(a, ",")
    Application.StatusBar = "Merging, please wait ..."
    Call MergePDFs(MyPath, MyFiles, DestFile)
    Application.StatusBar = False
    Else
    MsgBox "No PDF files found in" & vbLf & MyPath, vbExclamation, "Canceled"
    End If


    End Sub

  10. #30
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    Please start a new thread if you are not contributing to an active thread and need your own help.

    When posting a new thread and parts like the MergePDFs() routine is used, feel free to add a link to a post like this one that might be relevant. For new users, just say what thread number, e.g. 47310.

    When posting code, click the # icon to insert the code tags and paste between them.

    You can always attach a file so we can check things like references and such. Click the "Go Advanced" button to get the paperclip icon to do that. Post a simple file that isolates the problem if possible. The more you help us, the better and faster help you will get.

    For your issue, I am guessing maybe you have a conflict with your Constant variables. The MergePDFs() routine can easily be modified to include input parameters rather than Constant variables. Use F8 in the Visual Basic Editor (VBE) to step through your code one line at a time to debug. And/or, use Debug.Print to print intermediate results to the Immediate window during a run. Of course that does not help for a Compile issue. Compiling before a run is important.

    Without seeing all of your code, I am guessing maybe you did not include the MergePDFs() sub as another possible cause.

    Another cause can be the reference to the Adobe Acrobat object and registration of the object. Again, seeing an attachment can tell us that tell, if we have that object as well of course.

    Tip: Other parts of your code could use some tweaking. I noticed that you used Preserve. That can be used in building of the file names array rather than defining a huge array. There are other neat ways to do that sort of thing too. That is fodder for another thread of course.

  11. #31
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    Quote Originally Posted by blitzd13 View Post
    Im getting a Compile error at Call MergePDFS(MyPath, Myfiles, DestFile)
    Hi and welcome to VBAX!

    Seems the code of Sub MergePDFs has not been copied from post #4. It is required.
    Your attached example would avoid our guessing - please pay attention on Kenneth's recommendations.

    Regards

  12. #32
    The original coding supplied at the beginning of this thread worked perfectly for me. However I'd like to link this code with an Excel spreadsheet I'm developing. Basically, I have a checklist in Excel that allows the user to check which pdfs they want to have merged. Their selections either return a True/False or I can have it return a 0/1. These values are stored in a column in excel. I've made the checklist in the same order as the pdf files. I'm fairly new to VBA so any help is appreciated. Let me know if you need any additional information.

  13. #33
    VBAX Newbie
    Joined
    Jul 2015
    Posts
    1
    Location
    Hey ZVI,

    This code would be tremendously helpful for me, but I'm getting the "Run-time error 429: ActiveX component can't create object" Set PartDocs(i) = CreateObject("AcroExch.PDDoc") at as well. I also tried the early binding method.

    I manually set the reference to the Acrobat 10.0 Type Library, and can confirm that I have Acrobat Reader XI installed. Any other ideas why this wouldn't work?

    pdf snipp2.JPG

    Many thanks,
    Joe

  14. #34
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum! You should start your own thread and reference ones like this one if needed.

    Please read the posts in this thread. You have referenced the reader, not Adobe "Acrobat". As such, the class AcroExch.PDDoc is not in your registry and can not be referenced. The reference should just be shown as "Acrobat" as previously explained. The acrobat DLL and TLB files will be in your "c:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\" folder.

    Since you only have the reader, you will have to use a third party program to merge PDF files as explained. Of course one can include more than one worksheet to create a PDF using Excel's method.

  15. #35
    VBAX Newbie
    Joined
    Mar 2016
    Posts
    1
    Location
    The code works after adding the reference (in my case the acrobat.tdl), however after saving and closing the reference disappears. With the correct references the process works start to finish. When I reopen Excel and the reference has been replace to Acrobat 10.0 Type Library (and the .tdl is no longer checked) this happens:

    At this line: Set PartDocs(i) = CreateObject("AcroExch.PDDoc"), a dialog box opens that says:

    clip.jpg


    When I cancel and continue, the process works, but the idea is to have this run automatically. Neither suppressing ScreenUpdating nor EnableEvents works.

    I need to figure out how to persist the correct reference even after saving/closing or suppress this messaging.

    Thanks.

  16. #36
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum! You should start your own thread and reference ones like this one if needed.

    You should update your print driver to avoid that problem dialog. http://lfpp.csa.canon.com/main/produ...34374302162637

    Do you mean acrobat.tlb? I reference Acrobat.dll. Once added, your reference will then simple show as "Acrobat".

  17. #37

    Error!!! Urgent

    Hi i am getting the error of user defined type not defined. I am using Excel 2013 and the libraries available for me are
    1) Adobe Acrobat browser control type library 1.0
    2) Adobe reader file preview
    3)Acrobat access 3.0


    Capture.PNG
    Version is 15.010
    please help its very urgent
    Last edited by Shiva117; 08-18-2016 at 11:13 AM.

  18. #38
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    See post 34.

    You must have Acrobat installed and not just Adobe Reader.

  19. #39
    VBAX Contributor
    Joined
    Dec 2009
    Location
    Sevastopol
    Posts
    150
    Location
    The code works with Adobe Reader XI Pro installed

  20. #40
    Hi,

    Can we do it using Acrobat reader. if yes please share the code. even if I need to use third part controls please help me on this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •