Quantcast
Channel: PDFCreator - pdfforge forums
Viewing all articles
Browse latest Browse all 2619

VBA that uses PDFCreator crashes word after macro practically finishes

$
0
0

@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 :confused:

Here is the macro:

Sub mergePDF()
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)

Dim outPath$
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
Wend

Debug.Print "oPDF isinstancerunning: " & oPDF.IsInstanceRunning ’ close Excel and reopen if true.
'Stop

On Error GoTo EndSub
Dim q As PDFCreator_COM.Queue
Set q = New PDFCreator_COM.Queue
q.Initialize
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.
'Stop

q.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

Read full topic


Viewing all articles
Browse latest Browse all 2619

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>