How do you remove other instances in VBA?

I was previously using PDF creator 1.7 with MS Access VBA script. To detect if the another instance was running I used.

bPDFRestart = False
Set PDFjob = New PdfCreatorObj

                'PDF Creator is already running.  Kill the existing process
                If PDFjob.cStart("/NoProcessingAtStartup") = False Then
                    Shell "taskkill /f /im PDFCreator.exe", vbHide
                    Set PDFjob = Nothing
                    bPDFRestart = True
                End If
            Loop Until bPDFRestart = False

But recently I have upgraded to PDF Creator 2.3.2 so that I can install the same version on all the machines that will be using the database. I have been through the documentation and now check to see if the if another instance is running using the following

iCount = 0
MsgBox iCount
bPDFRestart = False
Set PDFObj = CreateObject(“PDFCreator.PDFCreatorObj”)

                'PDF Creator is already running.  Kill the existing process
                If PDFObj.IsInstanceRunning = True Then
                    Shell "taskkill /f /im creator-ws.exe", vbHide
                    Shell "taskkill /f /im crash-handler-ws.exe", vbHide
                    Set PDFObj = Nothing
                    bPDFRestart = True
                End If
                iCount = iCount + 1
            Loop Until bPDFRestart = False Or iCount = 10

Bu this does not seem to shutdown the instances of PDF creator and loops through 10 times before I stop the process.

I have used task manager to try to find the running instances and can only find running services. Is there an easier way to do this?

If I try to initialise the PDFQueue after setting it, I get this error,

Error Code :-2146233079
Error Description: Access forbidden. An instance of PDFCreator is currently running.

If I check for an instance using (PFDObj.IsinstanceRunning) and do not initialise if there is an instance running, at the point I try to set PDFjob =PDFQueue.nextjob, I get this error

Error Code :-2147467261
Error Description: Object reference not set to an instance of an object.

I need to be able check if another instance is running and remove it or be able to use that instance but I cannot find the correct coding.


you will need to use the ReleaseCom method of the Queue object as described here:

It shouold all be in that link, but feel free to ask if it doesn’t fully answer your question.

Best regards,


Hi Robin,

Thanks for the pointer, I had read through this, and used the example scripts with the PDFCreator. What appears to have happened is that the script had not completed after initialising in the first instance; even though I shut MS Access down and restarted, it still showed the instance as running. I completely reinstalled PDFCreator and added the following into the error capture of the VBA code.

Exit Sub

MsgBox "Error Code : " & Err.Number & vbCrLf & vbCrLf & _
"Error Description : " & Err.Description

If PDFObj.IsInstanceRunning = True Then
    MsgBox "Error has occured and there is another instance is running"
End If

Thus, ensuring that if the code should error again before the releasing the instance the instance would be released. This appears to have worked so far with the script now printing out the PDFs as required.