Microsoft KB Archive/184899

= PRB: SelPrint Method Issues an EndDoc When Printing =

Article ID: 184899

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q184899



SYMPTOMS
When you use the SelPrint method in Visual Basic, you receive unexpected results. If you execute an EndDoc method after a SelPrint, you may receive the following error:

Run-time Error #482:

Printer Error

Additionally, if you are printing information after the SelPrint method within the same print job, you may find that the information is not printed.



CAUSE
The SelPrint method of the Rich TextBox control that ships with Visual Basic 6.0 has an optional second argument. This argument determines whether the SelPrint method performs the StartDoc and EndDoc printer control operations, and sends data to the printer using only EndPage and StartPage operations as required. If you set this second argument to TRUE (or omit it), the SelPrint method performs the StartDoc and EndDoc operations. If you set this second argument to FALSE, the SelPrint method does not perform the StartDoc and EndDoc operations.



RESOLUTION
There are two solutions to this problem:


 * If you are not printing any information before or after the SelPrint method executes, do not use the EndDoc method and either omit the second argument of SelPrint or set it to True.
 * If you want to print additional information after the SelPrint method executes, set the second argument of SelPrint to False so that SelPrint does not issue an EndDoc before your print job completes.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Start a new project in Visual Basic. On the Project menu, click Components, and check "Microsoft Rich TextBox Control 6.0." Add a RichTextbox control to Form1.  Add the following code to the Click event of Form1: Printer.Print " " Printer.Print "Hello" RichTextBox1.SelPrint Printer.hDC Printer.Print "Bye" Printer.EndDoc

 Press F5 to run the project and then Form1.</li></ol>

RESULTS: You receive the run-time error 482. Additionally, you may notice that anything printed after the SelPrint method ("Bye" in this case) is not included in the output as expected.

Additional query words: kbVBp600 kbVBp kbdsd kbDSupport kbPrinting

Keywords: kbprb kbctrl KB184899

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.