Microsoft KB Archive/265126

= How To Print Contents of the Web Browser Control from Visual FoxPro =

Article ID: 265126

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q265126



SUMMARY
The Microsoft Web Browser control does not offer a Print method. This article demonstrates how to print the contents of the control from Microsoft Visual FoxPro.



Step-by-Step Instructions
 Create a new form, named frmWeb in Visual FoxPro. Add a command button, named cmdPrint, and an OLEControl, named oleWeb to the frmWeb form. Set the OLEControl to use the Microsoft Web Browser control.  Add the following code to the frmWeb.Init method: ThisForm.oleWeb.Navigate(&quot;http://msdn.microsoft.com/vfoxpro/&quot;)   Add the following code to the oleWeb.Refresh method: NODEFAULT  && Avoids &quot;Unspecified error&quot; on form startup   Add the following code to the cmdPrint.Click method: ThisForm.oleWeb.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)  Run the form. After the page loads, click the cmdPrint button, and the page prints to the default printer.</li></ol>
 * 1) DEFINE OLECMDID_PRINT 6
 * 2) DEFINE OLECMDEXECOPT_PROMPTUSER 1
 * 3) DEFINE OLECMDEXECOPT_DONTPROMPTUSER 2

<div class="references_section">