dcsimg
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
    Super Moderator 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
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  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,268

    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
  •  



Featured


Click Here to Expand Forum to Full Width