Click here to Skip to main content
14,208,191 members

Printer automation problem

Member 11683251 asked:

Open original thread
I'm trying to convert several documents to pdf via VB6. The documents are created by vb6 from a database and inserted into a report which I print using a pdf printer to a folder.

When I print a file I wish to move it and rename it to the correct filename. Got the code done to do so.

I've got a problem where the file isn't "printed" quick enough meaning I try to move a file which doesn't yet exist. I tried to sleep my program but that doesn't help, it seems the printing is done in the same thread as the program or something.

I've come up with several work arounds in my head but they all got their own problem. One was if I named the file differently then I could print one file, get the data and start printing the next one and then move back to the first one and do a move and rename. Basically trailing one print job all the time. But that is a no go atm because one problem is that I cant send an argument with what I want the filename to be. Bullzip which I use seems to take a window name as the filename, eg printing from notepad creates a file called notepad - openfile.pdf

My files gets named as MSDataReport.pdf. I'm curious if I can make this approach usable by getting the window using windows api?

The "best" results so far have been by adding a plain msgbox which pops up and then use a timed auto clicker to wait a few seconds and then press ok. It seems that the messagebox doesn't prevent the printing the same way as sleep does. This approach is risky and will lock my computer for the duration so it's not optimal either but atleast it saves me from a lot of manual labor.

Any thoughts on what I can do? Either improve my own solutions or other ways to work around this?
Tags: VB6


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190612.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100