Microsoft KB Archive/274523

= BUG: Print to File Fails to Request Output File Name =

Article ID: 274523

Article Last Modified on 9/28/2004

-

APPLIES TO

 Microsoft Visual Basic 4.0 Professional Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows Millennium Edition  Microsoft Visual Basic 5.0 Professional Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li> Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li> Microsoft Visual Basic 4.0 Enterprise Edition, when used with:  Microsoft Windows 95</li></ul>

<ul> <li>Microsoft Windows 98 Standard Edition</li></ul>

<ul> <li>Microsoft Windows Millennium Edition</li></ul> </li> <li>Microsoft Visual Basic 5.0 Enterprise Edition, when used with: <ul> <li>Microsoft Windows 95</li></ul>

<ul> <li>Microsoft Windows 98 Standard Edition</li></ul>

<ul> <li>Microsoft Windows Millennium Edition</li></ul> </li> <li>Microsoft Visual Basic 6.0 Enterprise Edition, when used with: <ul> <li>Microsoft Windows 95</li></ul>

<ul> <li>Microsoft Windows 98 Standard Edition</li></ul>

<ul> <li>Microsoft Windows Millennium Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q274523

<div class="symptoms_section">

SYMPTOMS
When the Print to File checkbox is selected in the Print dialog box, the dialog box that allows an Output File Name to be specified is not displayed.

<div class="resolution_section">

RESOLUTION
There are three possible workarounds for this behavior:
 * Check the Flags property of the CommonDialog control to see if the Print to File checkbox is marked. If the checkbox is marked, you can create a text file (without printer codes) with the Visual Basic Open, Write, and Close commands.


 * Configure a local printer to print to the FILE: port. This local printer can be used when a Print to File operation is required.


 * Open the Printer Common Dialog with WIN32 API functions, such as PrintDlg or PageSetupDlg, instead of with the comdlg32.ocx file. You can then print with API calls instead of the Printer object. See the &quot;References&quot; section of this article for more information.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> <li>Start a new Visual Basic Standard EXE project. Form1 is created by default.</li> <li>On the Project menu, select Components. In the Components dialog box, check the Microsoft Common Dialog Control component, and then click OK.</li> <li>Add a CommonDialog control to Form1.</li> <li> Add the following code to the General Declarations section of Form1: Private Sub Form_Click Dim blnUseWorkaround As Boolean

' Uncomment the following line to examine a workaround 'blnUseWorkaround = True

CommonDialog1.ShowPrinter If blnUseWorkaround Then ' Test to see if the Print to File box is checked If (CommonDialog1.Flags And cdlPDPrintToFile) = cdlPDPrintToFile Then MsgBox &quot;Create the Output file using the Open, Write, and Close commands&quot; Else PrintText End If   Else PrintText End If End Sub

Sub PrintText Printer.Print &quot;Test Text&quot; Printer.EndDoc End Sub </li> <li>Press the F5 key to run the program.</li> <li>Click on Form1, and note that the Print dialog box appears.</li> <li>Check the Print to File checkbox.</li> <li>Click OK on the Print dialog box, and note that the dialog box that requests an Output File Name is not displayed.</li></ol>

<div class="references_section">