@VincenTT wrote:
Hi all,
It seems that some of the jobs that put in the queue are being skipped and left in queue, making PDFcreator crash. It happens mostly following a bigger printed file .I have tried different wait to avoid queuing a new fob before the previous one finished, .isjobsucceful or finished, tried to release the com and initialize the queue before setting for a new job. they seem to not fixing the issue.
How can i make sure to only starting a new job when the previous is finished ?
Below is my code in vba excel:
Blockquote
Public Function SaveAs_PDF(WbPDF As Workbook, sPDFPath As String, sPDFName As String)
Dim PDFCreatorQueue As Queue
Dim PDFcJob As PrintJob
Dim GetPrinterName As Printers
Dim WaitJob2BinQeue As Integer
Dim PDFobT As PdfCreatorObjSet PDFobT = CreateObject("PDFCreator.PdfCreatorObj") Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue") WaitJob2BinQeue = 0 Do While PDFobT.IsInstanceRunning = True DoEvents Loop If PDFobT.IsInstanceRunning = True Then PDFCreatorQueue.ReleaseCom PDFCreatorQueue.Initialize
ReloadTheJob:
If WaitJob2BinQeue > 10 Then 'Clear the queue PDFCreatorQueue.ReleaseCom ' Init the queue PDFCreatorQueue.Initialize End If 'Send to queue the job WbPDF.PrintOut 'Background:=False 'Make sure the job arrived in the Queue Do Until PDFCreatorQueue.Count <> 0 WaitJob2BinQeue = WaitJob2BinQeue + 1 PDFCreatorQueue.WaitForJob (5) If WaitJob2BinQeue > 11 Then GoTo Endit If WaitJob2BinQeue > 10 Then GoTo ReloadTheJob Loop 'Set the job to print Set PDFcJob = PDFCreatorQueue.NextJob
'Set the printitng profile to use
PDFcJob.SetProfileByGuid ("DefaultGuid")'Launch the printing PDFcJob.ConvertTo (sPDFPath & sPDFName)
Endit:
PDFCreatorQueue.ReleaseCom
End Function
Preformatted text
Posts: 1
Participants: 1