I use the following code:
Dim folder As String
Dim PDFfilename As String
folder = "N:\Styringssystem\Database UDVIKLING\" 'CHANGE AS REQUIRED
If Right(folder, 1) <> "" Then folder = folder & ""
PDFfilename = Dir(folder & "*.pdf", vbNormal)
outPath = "n:\styringssystem\database udvikling\outputFile.pdf"
Dim oPDF As PDFCreator_COM.PdfCreatorObj
Set oPDF = New PDFCreator_COM.PdfCreatorObj
While Len(PDFfilename) <> 0
filnavn = folder & PDFfilename
PDFfilename = Dir() ' Get next matching file'
When I use it on a stand alone machine with the free version it works fine - when I use it on the terminal server I get a error on this line: oPDF.AddFileToQueue filnavn
The error is a run time error -2147024809 (80070057) with the message "Der må ikke bruges tomme stinavne". Translated from Danish: "You are not allowed to use empty path names"
When I check the log file, I can see this error:
2018-11-03 22:30:07.1262 [Error] pdfforge.PDFCreator.Core.DirectConversion.DirectConversionInfFileHelper.TransformToInfFileWithMerge: Error while coping ps-file in spool folder:
Typeinitialiseringsfunktionen for 'PdfTools.Pdf.Internal.NativeBase' udløste en undtagelse.
sorry for the trouble.
We will need to look into this.
The paid PDFCreator editions use some third party libraries from pdftools, which aren't included in the free version; this is probably the reason why the freeware doesn't have this issue.
A possible workaround might be to use the /merge command line parameter instead of the COM interface, as this uses a different workflow internally:
Thanks for answer.
Do I understand you correct if you mean this should work?
Dim stAppName As String
stAppName = "C:\Program Files\PDFCreator\pdfcreator.exe"
Call Shell("stAppName /OutputFile=n:\test.pdf" /Merge=n:\file_a.pdf /Merge=n:\file_b.pdf", 1)
I can't make it work..
it should work if you change the third line to
Call Shell("stAppName /OutputFile=n:\test.pdf" /Merge=n:\file_a.pdf n:\file_b.pdf", 1)
I just realized the example in the docs is incomplete and we will update it accordingly.
I can't make it work...
I need a functionality where I from VBA code can merge several pdf-files to one pdf. I has to work in the background without starting pdfcreator with prompts for user input.
Can pdfcreator give mig a code which works with COM on a terminal server or a command line which can do the trick - or can you recommed something else?
Thank you in advance
what went wrong? Did you get a prompt for the output location even though you specified the OutputFile parameter, or which prompt(s) did you get? We have in the past seen a few cases i which VBA doesn't play along nicely with COM, does the JS merge example in "PDFCreator\COM Scripts\JS Scripts\How To" work?
We will look into the COM issue and see if we can find the cause of it.
Any solution to the COM issue?
I tried to reproduce the issue with the merge sample from PDFCreator\COM Scripts\Word - VBA\Testpage2PDF.docm but it didn't have any issues.
Probably the issue is restricted to direct PDF input, if you print the PDFs to the queue and merge them afterwards it should work, does the seem like a suitable work around? Sumatra PDF can print PDFs to a dedicated printer in the background via command line, if your currently installed reader doesn't support this.
I now also tried merging PDFs directly, it worked without an error.
Does this modified sample work for you?
Dim PDFCreatorQueue As Variant
Dim printJob As Variant
Dim oPDF As Variant
Set oPDF = CreateObject("PDFCreator.PDFCreatorObj")
Set PDFCreatorQueue = CreateObject("PDFCreator.JobQueue")
If Not oPDF.IsInstanceRunning Then
MsgBox "Initializing PDFCreator queue..."
'change path to some existing test files
'Set printer if necessary
Application.ActivePrinter = "PDFCreator"
MsgBox "Waiting for the 2 jobs to arrive at the queue for 15 seconds..."
If Not PDFCreatorQueue.WaitForJobs(2, 15) Then
MsgBox "The print job did not reach the queue within " & " 15 seconds"
MsgBox "Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue"
MsgBox "Merging all available jobs now"
MsgBox "Now there are " & PDFCreatorQueue.Count & " job(s) in the queue"
MsgBox "Getting job instance"
Set printJob = PDFCreatorQueue.NextJob
'change output path as required
If (Not printJob.IsFinished Or Not printJob.IsSuccessful) Then
MsgBox "Could not convert the file: " & fullPath
MsgBox "Job finished successfully"
MsgBox "Releasing the object"
I tried the same thing with vb6 and the result is they still return error 'Empty Path is not legal'.
I have converted this code to vb6 code. Any suggestion?