Merge PDFs using VBA

TheQ1991

New Member
Joined
Jun 13, 2017
Messages
4
I have the following scenario:

I have up to 200 different folders on my desktop. In each of these folders, I have up to 15 different pdf files. So I might have the following:

Folder A: Maths.pdf , English.pdf , Science.pdf , Geography.pdf
Folder B: Maths.pdf , English.pdf , Geography.pdf
Folder C: Science.pdf , Geography.pdf

I have an excel file that contains the names of all the folders in column A, all the possible filenames that could be saved in each folder in column B.

What I want is an automatic process that combines all pdf in Folder A and names the new file Folder A. I want it to then loop and to do this for all 200 folders on my desktop.

Any ideas how I could do this?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
If you want to combine multiple pdfs into one pdf, every thread I've read on this subject states that you need Adobe Acrobat, not just Reader. If you don't have that, it's a non-starter. If you do, it's been covered many times before, but I don't have any links for the code solutions as it's not something I'd ever need.
 
Upvote 0
If you want to combine multiple pdfs into one pdf, every thread I've read on this subject states that you need Adobe Acrobat, not just Reader. If you don't have that, it's a non-starter. If you do, it's been covered many times before, but I don't have any links for the code solutions as it's not something I'd ever need.
Thanks Micron. I do have Adobe Acrobat.

The problem I have with the solutions I have found is that it requires me to know which files are in which folder in advance.
 
Upvote 0
You can loop over the possibilities and pass the names to the Dir function to test if the file exists. If not, it returns an empty string. Can't say if you combine one by one or create an array of file names and combine those because I've never needed to combine pdfs. HTH.
 
Upvote 0
I have up to 200 different folders on my desktop. In each of these folders, I have up to 15 different pdf files. So I might have the following:

Folder A: Maths.pdf , English.pdf , Science.pdf , Geography.pdf
Folder B: Maths.pdf , English.pdf , Geography.pdf
Folder C: Science.pdf , Geography.pdf

I have an excel file that contains the names of all the folders in column A, all the possible filenames that could be saved in each folder in column B.

What I want is an automatic process that combines all pdf in Folder A and names the new file Folder A. I want it to then loop and to do this for all 200 folders on my desktop.
There are several command-line tools which can be run from VBA to merge PDFs. See these threads:



 
Upvote 0

Forum statistics

Threads
1,223,867
Messages
6,175,062
Members
452,610
Latest member
Sherijoe

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top