Results 1 to 5 of 5

Thread: Printer will not finish until app is closed

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    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.

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    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.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,466

    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)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width