Printer will not finish until app is closed
VB6 app on WIndows 7. Either USB attached laser or XPS writer.
Printing works fine but I can't print another job until I close the app.
Using Printer.EndDoc when printing is finished. Tried Printer.KillDoc after that as well.
Pages format correctly, new pages generated properly. It just won't accept another job and it appears the spooler stays open until the app is closed, not just the form that does the printing.
Re: Printer will not finish until app is closed
have you tried
set Printer = Nothing
Of course you will have to instantiate the printer object again to use.
Re: Printer will not finish until app is closed
Or using the ClosePrinter API
Code:
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Re: Printer will not finish until app is closed
Actually both answers worked. The actual problem showed up while I was stepping through the program to check the value of hPrinter. Turns out the printer.endDoc was being skipped in an if/else section.
Sending my thanks while I kick myself.:(
Re: Printer will not finish until app is closed
Being able to make that sort of mistake makes it sound like you have a lack of (or poor) indenting.
For an explanation/example of how it should be, see the article What is indenting, and why should I do it? from our Classic VB FAQs (in the FAQ forum)