1

Topic: Join pdf files in one with the help pdftk

Good evening!
Help to force to execute a macro a command, writes that: it is not possible to find "c:\pdftk.exe *.pdf cat output combined.pdf". Check up, whether the name is correctly filled out and repeat attempt.

Sub pdfM ()
Dim objShell
Set objShell = CreateObject ("Shell. Application")
objShell. ShellExecute "c:\pdftk.exe *.pdf cat output combined.pdf"
End Sub

2

Re: Join pdf files in one with the help pdftk

Ser123;
Try to execute in command line this command c:\pdftk.exe *.pdf cat output combined.pdf

3

Re: Join pdf files in one with the help pdftk

To you  or to go?
Works such (but the result puts in Documents of the user):

Option Explicit
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103
Public Sub ShellAndWait (ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
' fill in the missing parameter and execute the program
If IsMissing (WindowState) Then WindowState = 1
hProg = Shell (PathName, WindowState)
' hProg is a "process ID under Win32. To get the process handle:
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, False, hProg)
Do
' populate Exitcode variable
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub
Sub pdfM ()
ShellAndWait "c:\Temp\pdftk.exe *.pdf cat output all.pdf", vbHide
End Sub

4

Re: Join pdf files in one with the help pdftk

P.S. Source codes too collects therefrom... Unexpectedly. It can only at me so, just downloaded with https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/ - like earlier differently worked...

5

Re: Join pdf files in one with the help pdftk

Hugo121;
Thanks big! Still subtracted that the command is not fulfilled because of inverted commas, them not enough. It is necessary to quote a way some times.
Can to whom it is useful, looks so:

Sub pdfxx3 ()
folderPDFexe = "c:\pdftk.exe"
folderPDFout = "c:\test\combined1.pdf"
folderPDFin = "c:\test\temp\*.pdf"
folderPDFin2 = "c:\test\temp \"
folderPDFexe = """" AND folderPDFexe AND """"
folderPDFout = """" AND folderPDFout AND """"
folderPDFin = """" AND folderPDFin AND """"
cmdStr = folderPDFexe AND "" AND folderPDFin AND "cat output" AND folderPDFout
Shell cmdStr, vbHide
' removal of a temporal folder
sFolder = "c:\test\temp"
Dim fso As Scripting. FileSystemObject
Set fso = New Scripting. FileSystemObject
fso. DeleteFolder (sFolder)
End Sub

Hugo121, prompt, please, at me the removal command in a macro deletes a folder earlier than the join command pdf files has time to fulfill. Function ShellAndWait helps to solve it?

6

Re: Join pdf files in one with the help pdftk

And still, if to whom it is useful, if a command pdftk to fulfill from VBA pdftk takes off with an error, long searched for the reason, the reason in absence libiconv2.dll a file, it should be downloaded and placed with system32 or SysWOW64

7

Re: Join pdf files in one with the help pdftk

Ser123, for the sake of interest
That tool which you use corrects  files can?
I have a tool which can but as it often happens, it cyrillic corrects
It is a question of library QuickPDF in free Lite versions
Wrote on soap to those who supports this library, but they alas do not answer....

8

Re: Join pdf files in one with the help pdftk

Catastrophe;
No, cannot