• Error Messages: Can't Initialize PDFCreator

    A problem than can occur when working with PDFCreator via code is that sometimes the code releases PDFCreator too early, and it isn't properly closed.

    What is happening?
    At the end of the PDFCreator routines on this site, we release PDFCreator with (a variation of) the following line:
    Set pdfjob = Nothing
    As long as the PDFCreator.exe task is (still) running, we'll get the error "Can't initialize PDFCreator." every time we try to run the PDF creation code:
    So if you're seeing the above error, the issue is that a PDFCreator process is running on your system. If you opened PDFCreator manually, you may not have closed it. Or, if you had previously run a PDFCreator routine, then it had not finished doing what it needed to do, so the process that was actually running on the system stayed alive. We can check this by going into the Task Manager, (right click the taskbar and choose Task Manager,) and verifying that a PDFCreator.exe task is running.

    Killing the running process:
    The very first thing that we need to do to enable our code to run again is to close the running instance of PDFCreator. The steps to do this are listed below, but you should take great care to follow them exactly. Killing the wrong process could cause damage to your system, so make sure that you have the correct process selected! (You may want to print this, as the Task Manager will sit on top of all of your open windows.)
    • Right click your taskbar
    • Select Task Manager
    • Click on the Processes tab
    • Click Image Name until your list is sorted in alphabetical order
    • Scroll down the list until you find PDFCreator.exe
    • Right click PDFCreator.exe and choose End Process
    • Once the process disappears, close the Task Manager

    The first thing you should check about your code:
    On March 1st, 2007, I updated all the PDFCreator articles on the site to change the way PDFCreator was released. Check your code to see if you have a loop near the end that looks something like this:

    'Wait until the PDFCreator queue is clear
    Do Until pdfjob.cCountOfPrintjobs = 0
    If you do, try changing it to the following:

    'Wait until the PDF file shows up then release the objects
    Do Until Dir(sPDFPath & sPDFName) <> ""
    The reason that this works, is that instead of checking to see when the file shows up in the destination directory, the second variation checks to see when the PDFCreator queue is clear. At that point you can properly release the objects and they will close properly.

    Alternative Solutions:
    This article was originally published with the steps listed below to pause the PDFCreator code as I didn't have a better method at the time. Rather than remove them outright, I decided to leave them as an alternate way to work around the problem of closing PDFCreator. The method that follows is anything but elegant, but it is effective.

    Alternative One - No time to adjust the code:
    If you don't have time sleuth your your code, you could try closing all extra running programs to give your RAM and processor as much resources as possible. Often that is enough to allow a PDFCreator loop to complete.

    The problems with this, obviously, are:
    • We shouldn't need to close down our other applications to do this
    • It won't always work
    • It's not reliable when deploying code to clients. (Their systems will have different resource loads.)

    Alternative Two - Coding a pause:
    We can deal with this issue by intentionally slowing down our code with a pause. Personally, this goes against my grain, and is the reason I kept pursuing a better way. I want my code to complete as fast as possible, but if you don't mind this method, it will work.

    The actual length of the pause that is required will depend on your system, your RAM, your processor, and how many applications you have open when the PDFCreator code is running. It may take some experimentation to get it correct, and you should be warned that it may not work on your client's PC. You may need to increase the pause there to be safe.

    The following line of code just will add a 3 second pause in the routine. To adjust this pause, just increase or decrease the 3 to as much or little as you need.

    Application.Wait Now + TimeValue("0:0:3")
    The code above should be inserted just before the PDF job is closed. I.e. In the case of the (pre-updated) Printing Worksheets To A PDF File article, each of the routines would end:

    'Wait until the PDF file shows up then release the objects
    Do Until Dir(sPDFPath & sPDFName) <> ""
    'Wait a bit longer for PDF Creator to finish
    Application.Wait Now + TimeValue("0:0:3")
    Set pdfjob = Nothing


    I'm afraid that you must be logged in to comment or leave a testimonial. I wish it could be otherwise, but I'm trying to keep my site spam free for everyone's benefit. If you don't yet have an account it's completely free to sign up, and a very quick process. Simply click here to Register. Not only can you post a comment here, but it gives you full access to posts questions in our forum as well!


    If you already have an account, and just haven't logged in yet, what are you waiting for? Login Now!

  • MVP Logo
  • Recent Forum Posts

    Bob Phillips

    Please help!

    This array formula will add up the sums


    Bob Phillips Yesterday, 08:46 PM Go to last post
    Bob Phillips

    Index/match with multiple match criteria

    When I said Q1, I meant Quarter 1, cell E31, not cell Q1.

    It most definitely does match your last upload, C8:C30 is the date which I parse,...

    Bob Phillips 2020-11-24, 06:44 PM Go to last post

    Consolidate paired data sets

    hi all,

    I have a sheet which contains data sets (3 rows per data set), see Product Level sheet of attachment. I want to consolidate and total...

    GLewis14 2020-11-24, 02:46 PM Go to last post

    Please help!

    What is the criteria for counting the quantity. Would be helpful if you provided a sample workbook showing what you have and what your expected results...

    alansidman 2020-11-24, 06:21 AM Go to last post

    Please help!

    I am trying to count two separate pieces of data which appear in the same excel column. The columns will have a date followed by a quantity so look something...

    cprop76 2020-11-24, 05:52 AM Go to last post