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:
Application.Visible = False
Application.DisplayAlerts = False
Dim folder As String
folder = ThisDocument.Path & Application.PathSeparator & "DATA"
If Right(folder, 1) <> “” Then folder = folder & ""
PDFfilename = Dir(folder & “*.pdf”, vbNormal)
outPath = ThisDocument.Path & Application.PathSeparator & “ZDRUZENO.pdf”
Dim oPDF As PdfCreatorObj
Set oPDF = New PdfCreatorObj
While Len(PDFfilename) <> 0
oPDF.AddFileToQueue folder & PDFfilename
PDFfilename = Dir() ' Get next matching file
Debug.Print "oPDF isinstancerunning: " & oPDF.IsInstanceRunning ’ close Excel and reopen if true.
On Error GoTo EndSub
Dim q As PDFCreator_COM.Queue
Set q = New PDFCreator_COM.Queue
q.WaitForJobs CountFiles(folder, “*.pdf”), 10
Debug.Print "q.Count: " & q.Count ’ Error-check: here it prints either 1 or 2. Should always be 2.
Dim job As PDFCreator_COM.printJob
While q.Count > 0
Set job = q.NextJob
Application.Visible = True
Application.DisplayAlerts = True