PDA

View Full Version : Merge two pdf files with partly same name in 2 different flders



sujittalukde
06-03-2018, 03:06 AM
I have two different folders say Folder1 and Folder2 in c:\.
Folder1 contains pdf files which counts may vary but are named as say
PartA.pdf
test1.pdf

Folder2 contains pdf files which counts may vary but are named as say
PartB.pdf
test2.pdf
Sect_1.pdf

I want a excel vba code which will look into Folder2 and append the files in Folder1 if -
> First four character matches with any file in Folder1
> the file of Folder2 should be appended after last page of file in Folder1
> save the new merged file into a new location.

For eg,
PartB should be appended to PartA after last page of PartA and the new file should be PartAB.pdf.
test2 should be appended to test1 after last page of test1 and the new file should be test12.pdf.

The code should ignore file named Sect_1.pdf in Folder2 as there is no file having first four character similar to it in Folder1.

Can this be done through vba in excel?