COM PdfCreator MergeFiles with Excel VBA


#1

Hi,
I want to merge pdf files throught Excel vba. I have read the documentation and I can merge the pdf files, so it´s OK.

The problem is that only works one of two times, the other time the some jobs didn´t arrive at Queue. That happens always 1 of 2 times: the second time, the fourth time... and so on
When this happens, the jobs didn´t arrive, because I get the message "The jobs didn´t arrive" (see code below)

If after I merge files, I restart Excel, then It doesn´t happen... but restart Excel every time is no good solution for users

When it doesen´t work (second time, fourth time...), is like the files continue in the Queue. If I try to print directly from excel (directly, not by code) then it appears some files in the PDFCreator memory (see image)

I have installed the latest version 3.2.2

This is the code I have used:

'File names
Const FILE1 As String = "C:\File1.pdf"
Const FILE2 As String = "C:\File2.pdf"
Const MERGED_FILE As String = "C:\Merge.pdf"

'declare objects
Dim oQueue As New PDFCreator_COM.Queue
Dim oPdfCreatorObj As New PDFCreator_COM.PdfCreatorObj
Dim oPrintJob As PDFCreator_COM.PrintJob

'initialize queue
oQueue.Initialize

'add files to queue
oPdfCreatorObj.AddFileToQueue FILE1
oPdfCreatorObj.AddFileToQueue FILE2

'wait for jobs for 15 seconds
If oQueue.WaitForJobs(2, 15) = False Then
MsgBox "The jobs didn´t arrive"
oQueue.ReleaseCom
Exit Sub
End If

'merge all jobs
oQueue.MergeAllJobs

'get the job and print it
Set oPrintJob = oQueue.NextJob
oPrintJob.SetProfileByGuid ("DefaultGuid")
oPrintJob.ConvertTo (MERGED_FILE)

'release
oQueue.ReleaseCom

Thanks!


#2

Hi,

I have seen this happen before and I think you can work around it by only initializing the queue once and releasing the COM object after you have finished merging all files. We will have a closer look at this for the next PDFCreator update.

Best regards

Robin


#3

Hi,

I´ve tried 2 options, but the result is still the same: it only works properly one of two times:

  • Option 1:
    Initialize Queue
    Merge fist time (works ok)
    Merge second time (dosen´t work)
    Release Queue

  • Option 2:
    Initialize Queue
    Merge (works ok)
    Release Queue
    Initialize and Release without merge
    This option only works 1 of 2 times.. like always

Can I try something more before the new version?
Thanks