Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to suppress print dialog

182 views
Skip to first unread message

Trent J. West

unread,
Mar 3, 2002, 4:45:38 AM3/3/02
to
I am trying to configure IE 5.5 or 6.0 to NOT display the
Print dialog, and instead to just print to the default
printer. This is in order to automate use of WinFaxPro in
an ASP application. My application will add an HTML
attachment to a FAX, and WinFaxPro will ask the registered
HTM application to print it. For most applications, it
just prints. For IE, it displays the Print dialog,
requiring user intervention and killing my server-based
app. Any way to keep this from displaying without a user
clicking a button?

Thanks,

Trent J. West

Krishna Kumar

unread,
Mar 4, 2002, 12:20:17 PM3/4/02
to
Hi Trent,

With regard to your post here, the only way to get IE to print without
displaying the dialog box is to use the webbrowser control in an activeX
control and then use the ExecWB method on it passing it the 'dont show
printer' option. (OLECMDEXECOPT_DONTPROMPTUSER)

WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0

Another way to do it if you dont want to use the webbrowser control is to
directly use the rundll32 command.

The mshtml.dll can be used for printing htm files using the PrintHTML
interface
that it offers. However, this would involve the print dialog box popping up
each time it is invoked. In cases where this command is used within an
automated environment, the dialog box poses as a hassle since it needs to
be
manually dismissed. The focus is to find a way for the dialog box to not
appear.
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>

As such the rundll and rundll32 commands were originally designed only for
internal use at Microsoft. But the functionality provided by them is
sufficiently generic that they are now available for general use. Now, the
PrintHTML interface offered by the MSHTML.dll file is used for the "Print"
and
the "PrintTo" functionality in Internet Explorer. One may however use this
interface to print an HTML file from the command line or from a
ShellExecute
command as follows:

rundll32.exe %systemroot%\SYSTEM32\MSHTML.DLL,PrintHTML "filename"

The above command opens the Print dialog box and upon confirmation, prints
the
file in question. This however, is not appropriate for automated
environments
since the manual interaction to the dialog box would not be appropriate.
But,
it is not possible to invoke the above command without the print dialog
popping up. So, we make a provision to automatically "dismiss" the dialog
box
as it appears so that the command may run unmonitored.

To this effect, we can use the Microsoft ScriptIt utility found at
http://www.microsoft.com/technet/prodtechnol/winntas/downloads/scriptit.asp
to automatically handle the dialog box as it pops up. The ScriptIt utility
would
be invoked as "ScriptIt scriptfile" from the command prompt and it would
execute the contents of the script file in order to check for the Print
dialog
box popping up and whenever it pops up, dismiss it by means of an "Enter"
key
stroke which basically prints the page on the default printer.

The script to perform the above operation is:

Rem contents of scriptfile

[SCRIPT]

Print+Status:={ENTER}

rem hit the "Enter" key on the print dialog box

The way it works is that the command "Print+Status:={ENTER}" looks for an
open
window with the title "Print" and with the text "Status:" somewhere within
the
window, and when one is found (our print dialog), it feeds the "Enter"
keystroke to the window. This dismisses the print dialog box as it pops up
and
the page gets printed. So, the workaround would be to invoke the "ScriptIt
scriptfile" command before the rundll32 command so that the dialog box is
taken care of. The above mentioned workaround is suitable for both NT/2000
and
98 clients.

Hope that helps

Thanks
Krishna - Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
© 2001 Microsoft Corporation.
All rights reserved.

0 new messages