Solved

Inconsistent behavior of ShellExecute in printing pdf and htm files, using VB6

Posted on 2004-04-15
4
520 Views
Last Modified: 2010-08-05
Help, please

I use the following to print documents from a VB6 app runing on Windows XP.

            ShellExecute hwnd, "PRINT", myPath2File, vbNullString, vbNullString, 0

If the document is .pdf, the printing is initiated, which is what I want.
If the document is .htm, the printers dialog box opens, which is not what I want.

Is there a way to avoid the printers dialog box, please?
0
Comment
Question by:Gordon_Atherley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:denago
ID: 10839063
Try running the following command:
      rundll32.exe mshtml.dll,PrintHTML filename
0
 

Author Comment

by:Gordon_Atherley
ID: 10841279
Thanks Denago

I've tried the command in various ways, but I've succeeded only in generating error messages. This problem may well be my lack of knowledge. I've looked at KB 164787, and I'm unclear just how and from where I should run the command.

Please could you add a line or two to show how to handle it within VB6?

Thank you

Gordon
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 250 total points
ID: 10848716
Each application has it's own "Print" functionality. IE's "Print" just includes the dialog whereas Acrobat's doesn't. The "rundll32.exe" shortcut is basically the same as right-clicking on an HTML file and selecting "Print".

You should just use SendKeys() to automate the Print Dialog window. It's not "neat" but it should do the job.
0
 

Author Comment

by:Gordon_Atherley
ID: 10849246
zzzzzooc

Neat SendKeys() may not be, but functional it definitely is! Thank you.

This is what I used

     ShellExecute hwnd, "PRINT", sPathFile, vbNullString, vbNullString, 0
     Wait 5
     SendKeys "%(P)"

The Wait, set abitrarily at 5 sec, is needed to give the Print dialog box time to materialize. It does so fleetinglly. Then the automation proceeds as desired.

Acknowledgement, too, to Denago, for the alert to rundll32.exe, which I can see uses for in other ways.

Gordon
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question