Printing from the IE Browser Control



I would like to print the content of the Web Browser window from within my application, but there's no Print method on the object. How do I do it?

There are a couple of ways to print HTML using IE. The easiest is to use the ExecWB method, which allows access to most of the menu options under program control. You can look up the OLECMDID codes on MSDN - to print the value is 6:

*** Parm2:  1 - Print Dialog, 2 - NoPrompt
THISFORM.oBrowser.ExecWB(6,2,0,0)

If you simply want to print an HTML document you can also call the MSHTML engine directly by using the following code:

lcFile = 'c:\temp\__preview.htm'
run /n rundll32 mshtml.dll,PrintHTML &lcFile

Note that this routine will prompt for a printer setup dialog.


Last Updated: 12/03/98