I want to merge more than 30 pdf files in a folder into one pdf file

suryu

Member
Local time
Today, 06:19
Joined
Apr 3, 2020
Messages
86
First i am creating pdf files from excel format sheet and it is getting save in one folder .......
1)If pdf file in folder is more than 30 then it should merge all pdf files into one pdf file

can anybody suggest how to do this using vba ?

I did below Code:

Sub CreatePdf_form()

Dim str AS String
Dim strFile As String

Dim strMyPath As String

Sheets("data").select
Range("A2").Select

str=Activecell.value

strMyPath=Activeworkbook.Path
chDir strMyPath

If Len(Dir(StrMyPath & "\" & "Form", vbDirectory))=0 Then

MkDir strMyPath & "\" & "Form"

End If

sheets("data").select
Activesheet.ExportASFixedFormat Type:=xlTypepdf, Filename:=strMypath & "\" & "Form" & "\" & strFile & ".pdf"

End sub
 
I think you may need a 3rd party software for merging PDFs.

Another approach:
IF you have a single block of code that creates all PDFs in one go, then maybe your code can 1) keep track of how many are being created, and 2) dump all the data on a single sheet as it runs (with appropriate page breaks), and then export that whole sheet as PDF if # > 30.
 
take a look at post #12 in this thread

 
@CJ_London
Many thanks for the link. I'm amazed it can be done without using the full version of Acrobat.
 
I'm amazed it can be done without using the full version of Acrobat.
It still uses another software. And there are more besides PDFCreator that could be used.
 
I'm aware that its using PDF Creator. As I said, I thought it was only possible with Acrobat but clearly not.
 
If able to go the route of 3rd party software, the nice thing is that a lot of them also provide command line programming. Which can then be utilized even IF they don't have libraries vba can reference.
 
I haven't tried it, but you might also want to take a look at this one as well. In case it helps...
 
Last edited:
There is also Foxit pdf sdk (denube).
 
If i were you, ill stick with acrobat.
 
getting error in handling DLL , what all refrences need to keep?
Did you actually download and install PDFCreator, along with registering the required DLL's and studying its documentation as to how to incorporate them into your VBA project?
 
Did you actually download and install PDFCreator, along with registering the required DLL's and studying its documentation as to how to incorporate them into your VBA project?
No is there any other approach for that ?
 
No is there any other approach for that ?
That's the point that I was trying to make in posts 2 and 5. The article linked to might not make this clear, but it uses a 3rd party app which probably will need to be installed to utilize that code. You'll have to study their documentation.
 
That's the point that I was trying to make in posts 2 and 5. The article linked to might not make this clear, but it uses a 3rd party app which probably will need to be installed to utilize that code. You'll have to study their documentation.
Ok i will try that ...thank you
 

Users who are viewing this thread

Back
Top Bottom