Article ID: 242483 - View products that this article applies to.
This article was previously published under Q242483
Using code that calls the PrintForm method can cause one or more of the following errors after you change a page level setting (for example, Orientation) or you try to print text to the same page:
Run-time error '482': Printer Error
Run-time error '486': Can't print form image to this type of printer
Running under Microsoft Windows NT or Windows 2000, the initial call to PrintForm after changing settings works but subsequent attempts fail. Running under Windows 95, Windows 98, or Windows Me, code that makes even a single call to the PrintForm method after changing Orientation or any other page level setting fails with one or more of the preceding errors.
You can circumvent this problem by not using PrintForm and instead employing WIN32 API code. See the References section below for descriptions of these methods.
Running under Windows NT or Windows 2000
Running under Windows 95, Windows 98, or Windows Me
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.
For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:
194022To download the latest Visual Studio service pack, visit the following Microsoft Web site:
(http://support.microsoft.com/kb/194022/EN-US/ )INFO: Visual Studio 6.0 Service Packs, What, Where, Why
(http://support.microsoft.com/kb/194295/EN-US/ )HOWTO: Tell That a Visual Studio Service Pack Is Installed
Prior to Visual Basic 6.0, the PrintForm method was completely self contained and ignored any settings made to the Printer object. This was because the Printer object and the PrintForm method each used its own Device Context (DC) for the current printer. Each had its own printer settings that did not affect any other DC. This also meant that PrintForm would end the current print job, start its own job, and end it when finished.
In order to give developers the ability to control printer settings for PrintForm and to allow the printing of text on the same pages with the form image, PrintForm was changed to use the DC of the Printer object. Thus, now you can change printer settings and your call to PrintForm uses them. However, when attempting this under Windows 95 or Windows 98, or when this is done multiple times within a print job under Windows NT or Windows 2000, the errors listed in the Symptoms section can occur. You can get around this problem by replacing PrintForm with WIN32 API code (see References below) or by using the EndDoc method, which ends the print job and allows a new job to start. Also, under Windows 95 and Windows 98, you can use the printer Common Dialog instead of direct assignments to Printer.Orientation. While using EndDoc allows you to print text in the same code that uses PrintForm, you still cannot put the form image and text on the same page. However, you can print text and your form image on the same page using API calls.
Steps to Reproduce Behavior
Windows NT and Windows 2000
Windows 95, Windows 98, or Windows Me
For additional information on WIN32 API alternatives to using PrintForm, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/161299/EN-US/ )HOWTO: Capture and Print the Screen, a Form, or any Window
(http://support.microsoft.com/kb/178076/EN-US/ )HOWTO: Use a PictureBox to Control Orientation Printing a Form
230502For additional information on an alternative way to change Orientation when using PrintForm, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/230502/EN-US/ )HOWTO: Print a Form That is Too Large for the Screen or Page
(http://support.microsoft.com/kb/198901/EN-US/ )Sample: PageSet.exe Programmatically Changes Default Printer
Article ID: 242483 - Last Review: August 7, 2007 - Revision: 2.3
Contact us for more help
Connect with Answer Desk for expert help.