• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2624
  • Last Modified:

URGENT!! Cancel Print Job Already in spool in VB6 using API or whatever

GRADE A for quick answer.  Windows 2000 using VB6.  A print job is submitted and I want to cancel the job in code.  What is the specific syntax to accomplish.

Scott C
0
clarkscott
Asked:
clarkscott
  • 7
  • 3
  • 2
1 Solution
 
Leo EikelmanCommented:
The syntax is:

Report.PrintOut False
0
 
clarkscottAuthor Commented:
I don't see this in VB documentation?????
Is there a REFERENCE file to support this?

I was expecting to see something involving an API?

Here's the situation:

Production environment.  Material is entered into database.  Upon entry, a (very expensive) bar code is printed. It's possible the computer system could be down or printer off-line.  If this is an extended period of time, the material will continue its 'journey' and the bar code will not be attached (currently it's a luxery - not mandatory).  The application sends the barcode print job to the printer automatically.  We can determine if the printer is working (a timer event checks for printer activity).  If the timer-event determines the printer is down (or other system down), we want to CANCEL the print job(s) from the que (we know the name of the print document).   We want to avoid having a dozen (or more - could be 100 jobs) print jobs waiting for an 'active' printer.  Since the material has already been passed to next process - we don't need - or want - the expensive bar code(s) printed.

We tried this:

Declare Function AbortDoc Lib "gdi32" (ByVal hdc As Long) As Long

Private Sub Command1_Click()
  AbortDoc Printer.hdc
End Sub

It didn't bomb - but it didn't cancel the job either????

Scott C.
0
 
Leo EikelmanCommented:
Is this what you were looking at?

http://www.devx.com/tips/Tip/12799


Leo
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Leo EikelmanCommented:
You can also look at this aPI

Public Declare Function EndDocPrinter Lib "winspool.drv" Alias "EndDocPrinter" (ByVal hPrinter As Long) As Long
0
 
clarkscottAuthor Commented:
leikelman,

thanks for the info.... but we still cannot clear the document from the print que.
We have a test program that 'sends' a document (barcode) to the printer via a command button.
We placed 'your' code in another button to CANCEL the job.  The program does not crash but (after waiting as long as if we cancelled from the Windows Printer dialog box) the job in the que does not clear.

We could simply allow Windows to dialog-box the user informing them of a printer error... but the VB form is modal and the Windows message doesn't pop-up in front.  Therefore... the program continues to stack print jobs in the que ...and so on.

We would settle for a method of determining the NUMBER of jobs in the printer que.  We could apply logic to look for a maximum jobs and then stop the program from printing if we see too many jobs (with the assumption that too many jobs = not printing).

Scott C
0
 
nffvrxqgrcfqvvcCommented:
Printer.Killdoc
0
 
nffvrxqgrcfqvvcCommented:
If you are refering to something tha is already printing than I don't think you will be able to do much, you could contact your printer manufacturer and ask them if they have an escape code to cancel or stop a print job. Once you have the escape sequence codes you can call Escape API to send directly to the printer.

How To Use PASSTHROUGH Escape to Send Data Directly to Printer
http://support.microsoft.com/kb/q96795/
0
 
clarkscottAuthor Commented:
The print job is NOT currently printing.  We've been testing by taking the printer offline (since this is one of the reasons we want to be able to cancel all print jobs).



Scott C
0
 
clarkscottAuthor Commented:
It will be several hours before I return to the job and continue testing these suggestions.

Scott C
0
 
clarkscottAuthor Commented:
I was called to a different job and did not have a chance to test this.... will resume next week.

Scott C
0
 
clarkscottAuthor Commented:
I was not able to get this to work??  No errors.... just doesn't work.

I appreciate the effort trying to answer this question... the fact that there were no errors detected, but no success (I'm guessing) may have something to do with our system and specific hardware.

Thanks

Scott C
0
 
clarkscottAuthor Commented:
... some points for the effort!!!

Scott C
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now