Results 1 to 9 of 9

Thread: Getting Cancel Print Error#32755 (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378

    Getting Cancel Print Error#32755 (Resolved)

    Hello Y'all,

    In printing from a Rich Text Box, when I click on the Cancel print button, I get an error that says error message #32755

    "Cancel was chosen"

    How can I get around this?

    Here is my code:

    VB Printer Code

    On Error GoTo ErrorHandler
    If rtfText Is Nothing Then Exit Sub


    With CommonDialog1
    .DialogTitle = "Print"
    .CancelError = True
    .Flags = cdlPDReturnDC + cdlPDNoPageNums
    If rtfText.SelLength = 0 Then
    .Flags = .Flags + cdlPDAllPages
    Else
    .Flags = .Flags + cdlPDSelection
    End If

    Dim RESPONSE As Integer

    RESPONSE = MsgBox("Are you sure you want to print ~" & Text2 & "~? If NO, click CANCEL now. If YES, click OK now. Don't click the CANCEL button on the next screen or an error will occur and the program will simply end. ", vbOKCancel, "ABOUT TO PRINT " & Text2.Text)

    If RESPONSE = vbCancel Then

    Exit Sub
    End If

    .ShowPrinter

    If Err <> MSComDlg.cdlCancel Then
    rtfText.SelPrint .hDC

    End If

    End With

    ErrorHandler:
    Exit Sub

    End Sub
    Last edited by GARY MICHAEL; Jan 8th, 2003 at 06:55 PM.
    Thanks,
    GARY

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Change:

    .ShowPrinter


    to:

    On Error Resume Next
    .ShowPrinter



    The line ".CancelError = True" says that if the user presses cancel you know about it (unfortunately in the form of an error). The extra line above will force the program to continue so that you can check the error, rather than crashing.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378
    Thanks, si_the_geek for your reply. I still get exact same error.



    Thanks,
    GARY

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    ok, try this:

    VB Code:
    1. ...
    2. On Error GoTo ErrorHandler
    3. If rtfText Is Nothing Then Exit Sub
    4.  
    5. With CommonDialog1
    6.   .DialogTitle = "Print"
    7.   .CancelError = True
    8.   .Flags = cdlPDReturnDC + cdlPDNoPageNums
    9.   If rtfText.SelLength = 0 Then
    10.     .Flags = .Flags + cdlPDAllPages
    11.   Else
    12.     .Flags = .Flags + cdlPDSelection
    13.   End If
    14.  
    15.   On Error Resume Next
    16.   .ShowPrinter
    17.  
    18.   If Err = 0 Then
    19.     On Error GoTo ErrorHandler
    20.     rtfText.SelPrint .hDC
    21.   End If
    22.  
    23. End With
    24.  
    25. Exit Sub
    26. ErrorHandler:
    27.    Msgbox err.description, vbcritical ,"Error " & err.number
    28.  
    29. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378
    si_the_geek, I just replaced my code with yours and I still get the error, "Cancel was Selected". Have you tryed this code on your computer? If it works on yours I would think that it ought to work on mine. Huh? Maybe my computer is acting a fool! I hope not.
    Thanks,
    GARY

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    it works fine on mine, and always has done... if you search this forum for other examples of common dialog cancel, you'll see they are all the same.

    Two possible things that could be wrong - the common dialog control/VB have become corrupt (help!!)

    ..or more likely - you have got your VB settings to break on all errors rather than "break in class module".. check under "tools" -> "options" -> "general"

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378
    Thanks, I'll check that out and get back to you.
    Thanks,
    GARY

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2002
    Location
    Tennessee
    Posts
    378
    si_the_geek, You are GOOD! Real good. It worked. My setting was just as you suspected. I NEVER would have figured that out, but I know now. Thanks a million.
    Thanks,
    GARY

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by GARY MICHAEL
    si_the_geek, You are GOOD! Real good. It worked. My setting was just as you suspected. I NEVER would have figured that out, but I know now. Thanks a million.

    It's just one of those things you pick up after a while - when you are debugging it's a useful thing to turn on, but it doesn't come back to normal by itself

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