I want to merge more than 30 pdf files in a folder into one pdf file (1 Viewer)

suryu

Member
Local time
Today, 10:36
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
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:06
Joined
Mar 14, 2017
Messages
8,774
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.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 06:06
Joined
Feb 19, 2013
Messages
16,607
take a look at post #12 in this thread

 

isladogs

MVP / VIP
Local time
Today, 06:06
Joined
Jan 14, 2017
Messages
18,209
@CJ_London
Many thanks for the link. I'm amazed it can be done without using the full version of Acrobat.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:06
Joined
Mar 14, 2017
Messages
8,774
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.
 

isladogs

MVP / VIP
Local time
Today, 06:06
Joined
Jan 14, 2017
Messages
18,209
I'm aware that its using PDF Creator. As I said, I thought it was only possible with Acrobat but clearly not.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:06
Joined
Mar 14, 2017
Messages
8,774
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:06
Joined
Oct 29, 2018
Messages
21,454
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:

suryu

Member
Local time
Today, 10:36
Joined
Apr 3, 2020
Messages
86

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:06
Joined
May 7, 2009
Messages
19,231
There is also Foxit pdf sdk (denube).
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:06
Joined
May 7, 2009
Messages
19,231
If i were you, ill stick with acrobat.
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:06
Joined
Mar 14, 2017
Messages
8,774
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?
 

suryu

Member
Local time
Today, 10:36
Joined
Apr 3, 2020
Messages
86
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 ?
 

Isaac

Lifelong Learner
Local time
Yesterday, 22:06
Joined
Mar 14, 2017
Messages
8,774
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.
 

suryu

Member
Local time
Today, 10:36
Joined
Apr 3, 2020
Messages
86
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

Top Bottom