Results 1 to 7 of 7

loop trough all folders and subfolders and merge pdf files

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    loop trough all folders and subfolders and merge pdf files

    Hi all,

    I found the below code:
     Sub Button1_Click()
    
        Dim AcroApp As Acrobat.CAcroApp
    
        Dim Part1Document As Acrobat.CAcroPDDoc
        Dim Part2Document As Acrobat.CAcroPDDoc
    
        Dim numPages As Integer
    
        Set AcroApp = CreateObject("AcroExch.App")
    
        Set Part1Document = CreateObject("AcroExch.PDDoc")
        Set Part2Document = CreateObject("AcroExch.PDDoc")
    
        Part1Document.Open ("C:\temp\Part1.pdf")
        Part2Document.Open ("C:\temp\Part2.pdf")
    
        ' Insert the pages of Part2 after the end of Part1
        numPages = Part1Document.GetNumPages()
    
        If Part1Document.InsertPages(numPages - 1, Part2Document,
    		0, Part2Document.GetNumPages(), True) = False Then
            MsgBox "Cannot insert pages"
        End If
    
        If Part1Document.Save(PDSaveFull, "C:\temp\MergedFile.pdf") = False Then
            MsgBox "Cannot save the modified document"
        End If
    
        Part1Document.Close
        Part2Document.Close
    
        AcroApp.Exit
        Set AcroApp = Nothing
        Set Part1Document = Nothing
        Set Part2Document = Nothing
    
        MsgBox "Done"
    
    End Sub
    on this link:
    http://khkonsulting.com/2009/03/adob...-introduction/

    I need to adjust it to get the path of the file from excel sheet, starting at row 2 and down. It is possible that it will have only a few or a lot and with different names.

    how to create a loop that will set the part 1, part 2 and so on depending on how many files there are in the folder and subfolders.
    and, the maybe harder part would be to add also the names of the files as bookmarks in the merged pdf file.

    greetings.
    Last edited by Megatronixs; 10-23-2018 at 09:49 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code to loop through folders and subfolders under date time conditions ?
    By hopeful_positive in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2018, 11:45 AM
  2. how to copy and paste folders / subfolders and files
    By ColemanJames in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2018, 07:32 PM
  3. Loop through folders and subfolders - Tweaking existing code
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-29-2016, 09:20 AM
  4. [SOLVED] Search for files in folders and subfolders
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2014, 08:43 AM
  5. Loop trough all folders and subfolders and copy data
    By forfiett in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-20-2013, 10:22 AM
  6. Map/List of folders, subfolders & files
    By Bogdan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2006, 01:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1