@NN_NN wrote:
At work I’m using Office365. I’m also using PDFCreator with Word macro to merge PDF files from one folder into one PDF file. After macro finishes and succesfully creates merged PDF file (and Word is visible again) I receive the following error: https://imgur.com/a/FOFQi
I think it translates into error: “Microsoft Word has stopped working; Windows is trying to recover your files”; and gives me the option to close Word.I’ve put stop before and after “job.ConvertTo (outPath)”. First stop goes through, after it stops on second stop and after it performs job.ConvertTo it produces te same error.
How can I solve this problem? This is only one of the steps in a bigger procedure and is not the last step
Here is the macro:
Sub mergePDF()
Application.Visible = False
Application.DisplayAlerts = FalseDim folder As String
folder = ThisDocument.Path & Application.PathSeparator & "DATA"
If Right(folder, 1) <> “” Then folder = folder & ""
PDFfilename = Dir(folder & “*.pdf”, vbNormal)Dim outPath$
outPath = ThisDocument.Path & Application.PathSeparator & “ZDRUZENO.pdf”Dim oPDF As PdfCreatorObj
Set oPDF = New PdfCreatorObjWhile Len(PDFfilename) <> 0 oPDF.AddFileToQueue folder & PDFfilename PDFfilename = Dir() ' Get next matching file Wend
Debug.Print "oPDF isinstancerunning: " & oPDF.IsInstanceRunning ’ close Excel and reopen if true.
'StopOn Error GoTo EndSub
Dim q As PDFCreator_COM.Queue
Set q = New PDFCreator_COM.Queue
q.Initialize
q.WaitForJobs CountFiles(folder, “*.pdf”), 10Debug.Print "q.Count: " & q.Count ’ Error-check: here it prints either 1 or 2. Should always be 2.
'Stopq.MergeAllJobs
Dim job As PDFCreator_COM.printJob
While q.Count > 0
Set job = q.NextJob
job.SetProfileByGuid (“DefaultGuid”)
job.ConvertTo (outPath)Wend
EndSub:
q.ReleaseCom
Application.Visible = True
Application.DisplayAlerts = True
End Sub
Posts: 1
Participants: 1