Results 1 to 3 of 3

Thread: Cancel Printing still Prints

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Cancel Printing still Prints

    I made a program that prints a "report form"

    this is the code im using

    VB Code:
    1. On Error GoTo prolem
    2.   With CommonDialog1
    3.   .ShowPrinter
    4.   .CancelError = True
    5.   NumCopies = .Copies
    6. End With
    7.   For i = 1 To NumCopies
    8.     Me.PrintForm    ' Prints the form using the print dialog info
    9.   Next i
    10.   Exit Sub
    11. prolem:
    12. Exit Sub

    When the user clicks cancel it still prints !!!!
    how can i ammend this

    Thanks all
    Sam Lad

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Swap the ".ShowPrinter" and ".CancelError = True" lines

    the work is done (and thus the error occurs) in the ShowPrinter method, so if CancelError isn't set before then, it wont give an error.

  3. #3
    You can also use this

    GoTo drain
    ' =================
    '
    ' Here on error trap of [Cancel], pass falsity back
    '
    trapped:
    ArmPrinter = False
    Resume drain
    ' = = = = = = No fallthru
    '
    drain:

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