|
-
Jan 6th, 2003, 09:50 AM
#1
Thread Starter
Hyperactive Member
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
-
Jan 6th, 2003, 10:40 AM
#2
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.
-
Jan 6th, 2003, 08:38 PM
#3
Thread Starter
Hyperactive Member
Thanks, si_the_geek for your reply. I still get exact same error.
-
Jan 7th, 2003, 05:51 AM
#4
ok, try this:
VB 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
On Error Resume Next
.ShowPrinter
If Err = 0 Then
On Error GoTo ErrorHandler
rtfText.SelPrint .hDC
End If
End With
Exit Sub
ErrorHandler:
Msgbox err.description, vbcritical ,"Error " & err.number
End Sub
-
Jan 7th, 2003, 08:56 AM
#5
Thread Starter
Hyperactive Member
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.
-
Jan 7th, 2003, 11:05 AM
#6
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"
-
Jan 8th, 2003, 06:41 PM
#7
Thread Starter
Hyperactive Member
Thanks, I'll check that out and get back to you.
-
Jan 8th, 2003, 06:54 PM
#8
Thread Starter
Hyperactive Member
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.
-
Jan 9th, 2003, 06:00 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|