Microsoft KB Archive/254925

= PRB: Printer Object Fails to Track Default Printer =

Article ID: 254925

Article Last Modified on 5/12/2003

-

APPLIES TO


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

-



This article was previously published under Q254925



SYMPTOMS
After you change the Printer.Orientation property, the Printer object does not track the default printer again.



CAUSE
The Printer.Orientation property call changes the Printer.TrackDefault property to False so that the Printer object will not use the default orientation.



RESOLUTION
To resolve this problem add the following line of code before the line to change printer settings: Printer.TrackDefault = True



STATUS
This behavior is by design.



Steps to Reproduce Behavior
Use the following steps to reproduce this behavior:  Install two printers onto your computer and name them Printer 1 and Printer 2. Make Printer 1 the default printer. Create a Standard EXE project with Microsoft Visual Basic 6. Form1 is created by default. From the Project menu, select Components. In the Components dialog box, select the "Microsoft Common Dialog Control" check box and then click OK. The Common Dialog control's icon is added to the Toolbox. Add a Common Dialog control to Form1.  Add a CommandButton named Command1 to Form1 and then insert the following code into the code window of Form1: Private Sub Command1_Click Printer.Orientation = 2 CommonDialog1.ShowPrinter Debug.Print Printer.DeviceName End Sub </li> Press F5 to run the project. Click Command1 and Printer 1 displays in the Printer dialog box as the current default printer. Choose Printer 2 from the drop down list, and then click OK to make Printer 2 the default Printer. You then see Printer 1 displayed in the immediate window instead of Printer 2.</li>  Go back to design mode and add the following line of code: Printer.TrackDefault = True Before this line: CommonDialog1.ShowPrinter </li> Press F5 to run the project again and now it works as expected.</li></ol>

Additional query words: Orientation TrackDefault

Keywords: kbprint kbcmndlgprint kbprb KB254925

-

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

© Microsoft Corporation. All rights reserved.