Merge via com wrong order


I am using vba to do a merge via com using code written by Kenneth Hobson (see below). However when I merge 100 files I find that the files do not always appear in the correct order in the merged document.

Any help would be gratefully appreciated. Thanks

’ Macro Purpose: Print to PDF file using PDFCreator v2.3.2, Kenneth Hobson, Oct. 8, 2016
’ Designed for early bind, set reference to: PDFCreator - Your OpenSource PDF Solution
’ sPDFName() assumed to be 0 index based string array.
Sub PDFCreatorCombine(sPDFName() As String, sMergedPDFname As String, Optional tfKillMergedFile As Boolean = True)
Dim oPDF, msg

Dim q As Queue
Dim pJob As PrintJob

Dim pj As PrintJob
Dim i As Integer, ii As Integer
Dim fso As Object, tf As Boolean
Dim s() As String

On Error GoTo EndSub

Set oPDF = CreateObject("PDFCreator.PDFCreatorObj")

If oPDF.IsInstanceRunning Then
    Err.Raise Number:=11111, Description:="PDF creator is running"
End If

Set q = CreateObject("PDFCreator.JobQueue")


Set fso = CreateObject("Scripting.FileSystemObject")
If tfKillMergedFile And fso.FileExists(sMergedPDFname) Then Kill sMergedPDFname

For i = 0 To UBound(sPDFName)
    If fso.FileExists(sPDFName(i)) Then
        ii = ii + 1
        ReDim Preserve s(1 To ii)
        s(ii) = sPDFName(i)
    End If
Next i

tf = q.WaitForJobs(ii, 5)    'Wait 5 seconds for jobs to que

For i = 1 To UBound(s)
    oPDF.AddFileToQueue s(i)
Next i


Set pj = q.NextJob
With pj
    .SetProfileByGuid "DefaultGuid"
    .SetProfileSetting "Printing.PrinterName", "PDFCreator"
    .SetProfileSetting "Printing.SelectPrinter", "SelectedPrinter"
    .SetProfileSetting "OpenViewer", "false"
    .SetProfileSetting "OpenWithPdfArchitect", "false"
    .SetProfileSetting "ShowProgress", "true"
    .ConvertTo sMergedPDFname
End With

If Err.Number <> 0 Then
msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & "Error Line: " & Erl & Chr(13) & Err.Description
MsgBox msg, , “Error”, Err.HelpFile, Err.HelpContext
End If
End Sub