KillDoc Method Example

This example uses the KillDoc method to terminate the current print job. To try this example, paste the code into the Declarations section of a form, and then press F5 and click the form.

Private Sub Form_Click()
   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
End Sub