Using ShellExecute to Print an HTML file to the default printer

Experts,

I am trying to use ShellExecute to print an HTML file to the default printer without popping the dialog up.  I have read about using the "printto" verb, but can't figure out the exact syntax to get it to work.

I have first been trying to get it to work when I hardcode the name of my default printer.  Then I need to figure out how to obtain the name of the default printer and send it to it.

Here is my current code:

ShellExecute(NULL, "printto", path, "\"Adobe PDF\"", NULL, SW_HIDE);

But it still pops up the dialog.  Anyone been able to get this to work?

Thanks,
David
david_johnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alkisgCommented:
printto actually calls
rundll32.exe %SystemRoot%\system32\mshtml.dll,PrintHTML "%1" "%2" "%3" "%4"

So the question is, what are the four parameters of PrintHTML function.
It was also asked in
http://www.experts-exchange.com/Databases/FoxPro/Q_20862749.html
but it wasn't answered...

The first parameter is the filename
The second parameter is the printer
...and I haven't been able to find out the rest two (IF they really exist, it's not certain)!
It *may* be impossible to do it with printto/PrintHTML.

As reported in this link,
http://groups.google.com/group/microsoft.public.windows.inetexplorer.ie5.programming.misc/msg/abf8685b1b4259ea?q=%22mshtml.dll%22+printhtml+default+printer&hl=en&lr=&ie=UTF-8&rnum=3
the only way to print without a dialog is by sending the following command to a webbrowser control:
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0

Here's some code to get to started (C#, but no big differences from C++)
http://www.codeproject.com/csharp/printhml.asp
david_johnsAuthor Commented:
This is actually how I currently perform the task.  I was hoping for a lighter way of doing it, but perhaps it isn't possible.
itsmeandnobodyelseCommented:
Here check that link:  http://www.robvanderwoude.com/index.html

The author posted a batch file (version 2) which ought to supress the popup dialog ...

Regards, Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

david_johnsAuthor Commented:
Alex,

Great lead.  The only thing I don't like about his approach is his use of this 'Kix' utility to do all the work.  Is there a way too use VBScript to do the same thing?  I know VBA has a 'SendKeys' function too.  Anyone know if this is available in VBA?

Thanks,
David
david_johnsAuthor Commented:
Sorry - on the last line I meant anyone know if this is available in VBScript.
david_johnsAuthor Commented:
Alex,

Thanks for the lead.  I have not had any more time to look into using a VBScript to do the same thing that the Kix utility does, but you certainly gave me a branch to go down to find the solution that works for me.

If anyone comes up with this script I will open a new question and reward them with points too!

Thanks,
David
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.