change the subs to this, it will combine then delete the initial pdfs.
Sub ActualCombine(ByVal sPath As String, sOutFile As String)
'
' sPath is the path (folder) where your all pdfs exists
' sOutfile is the name of your output pdf (example, "Output.pdf")
Dim sFile As String
Dim cmd As String
Dim dict As Object
Dim i As Integer, j As Integer
Set dict = CreateObject("scripting.dictionary")
sPath = Replace$(sPath & "\", "\\", "\")
'put all the .pdfs in the dict object
sFile = Dir$(sPath & "*.pdf")
While Len(sFile) <> 0
dict(sFile) = 1
sFile = Dir$
Wend
j = -1
'check if there is any pdf
If dict.Count <> 0 Then
For i = 0 To dict.Count - 1
'find Output.pdf
'delete it only if there are other pdfs,
'otherwise, leave it
If dict.keys()(i) = sOutFile And dict.Count > 1 Then
Kill sPath & sOutFile
j = i
End If
Next
End If
' if we delete Output.pdf, remove it from the
' pdf list
If j > -1 Then
dict.Remove (dict.keys()(j))
End If
' recheck it again
If dict.Count = 1 And dict.keys()(0) = sOutFile Then
Else
cmd = "pdftk.exe " & sPath & "*.pdf cat output " & sPath & sOutFile
Shell cmd, vbHide
'now delete all pdfs on the list
For i = 0 To dict.Count - 1
Kill sPath & dict.keys()(i)
Next
End If
Set dict = Nothing
End Sub
' this is the test sub
' to test CombinePDF() function
Public Sub CombinePDF()
Dim sPath As String
sPath = "C:\MIHAI\DOC\ASIG\DOSARE"
'call the combine pdf routine
Call ActualCombine(sPath, "Output.pdf")
MsgBox "Pdfs combined to Output.pdf"
End Sub