Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KillDoc problem in VB 6

Status
Not open for further replies.

wangsx

Programmer
Mar 17, 2004
11
CA
When I use the Print.KillDoc routine to quit the printing job the application will be hooked. How can I do if I want to cancel the printing job?
Thanks.
 
did you mean Printer.KillDoc? If so, I use it all the time to kill a document in my error handlers. Are you saying it is making your program stop responding?
 
Yes, it is a problem of Printer.KillDoc. Even the sample code from VB 6 (listed below) results in the same problem when running the Printer.KillDoc routine. If nothing being printed the KillDoc routine works well otherwise the application will be hooked. I don't know if it is a problem of VB installation. Could you please try the code and see what happens on your machine?
Thanks very much for your help.


-----------------------------------------------
'adopted from VB 6 help of KillDoc
For i = 1 To 40
Printer.CurrentX = 1440 ' Set left margin.
Printer.CurrentY = (i * 300) ' Advance page to next line.
Printer.Print "This is line" & Str$(i) & " of text."
On Error Resume Next ' Catch any printer error.
If i = 26 Then
Printer.KillDoc ' Terminate print job abruptly.
Printer.EndDoc
End
End If
Next i
-----------------------------------------------
 
Yes, it is a problem of Printer.KillDoc. Even the sample code from VB 6 (listed below) results in the same problem when running the Printer.KillDoc routine. If nothing being printed the KillDoc routine works well otherwise the application will be hooked. I don't know if it is a problem of VB installation. Could you please try the code and see what happens on your machine?
Thanks very much for your help.


-----------------------------------------------
'adopted from VB 6 help of KillDoc
For i = 1 To 40
Printer.CurrentX = 1440 ' Set left margin.
Printer.CurrentY = (i * 300) ' Advance page to next line.
Printer.Print "This is line" & Str$(i) & " of text."
On Error Resume Next ' Catch any printer error.
If i = 26 Then
Printer.KillDoc ' Terminate print job abruptly.
Printer.EndDoc
End
End If
Next i
-----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top