Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Using ShellExecute to print

Status
Not open for further replies.

Apata

Programmer
Apr 5, 2006
52
US
I am trying to use ShellExecute to print a html file using the following code:
Code:
DECLARE INTEGER ShellExecute IN shell32.dll ;
   INTEGER hndWin, STRING cAction, STRING cFileName, ;
   STRING cParams, STRING cDir, INTEGER nShowWin

=ShellExecute(0,"PRINT","c:\Test.htm","","",1)

But I am getting the following error:
Ambiguous name detected: TMpDDE

Is the ShellExecute command stable, or is there a way to bring a html file into a report to print?
 
Hi Apata,

ShellExecute() is certainly stable.

The error you are seeing is not from ShellExecute(). It is produced by whichever application is registered in your system to print HTML files.

Your code works perfectly for me (using FireFox).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Adapta,

Just to add a note ...

I just tried your code on a machine for which Internet Explorer is the registered application to print HTML. It worked fine on that system as well.

Which suggests there's something wrong with web your browser configuration. Can you try your code on a different machine?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike. I'm using the new Internet Explorer 7.0. Since there are many browsers out there, how should I ensure that the code would not break on the user's machine? Is there a workaround?
 
Apata,

Good that you have solved it. Presumably you are using Microsoft Word to print the HTML -- judging by the reference you gave me. I don't understand the macro issue, but if it works, that's the main thing.

You asked about printing directly from an ActiveX Web control. Yes, this is possible. Basically, you use the ExecWB function. For an example, see my "Printing and reporting Q&A", at:

I know other people have had problems using this technique, but it might still be worth persuing.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks very much Mike. This works great!

It eliminates the flickering effect of the Shellexecute print command.

It also puts header and footer information, including the document name. Is there a way to change the header/footer information to something different or to eliminate part of the header/footer information? Thanks again.
 
Apata,

Is there a way to change the header/footer information to something different or to eliminate part of the header/footer information?

You would normally do this via the Internet Explorer user interface. (Something like File / Page Setup, but it probably varies in different versions.)

If you are looking for a way to do it programmatically, you might try using ExecWB again. I can't give you any details, but in general ExecWB lets you execute any menu command in the IE interface. The first parameter is an integer that corresponds to the menu commandn in question.

Hope this helps.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Apata,

Given that you've already got code in place to do the printing, it shouldn't be too hard to add some more code to do the page setup. It's the same ExecWB method, but with different parameters.

My advice would be not to get bogged down with trying to convert C++. Instead, focus on trying to find the parameters to ExecWB.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks again Mike. I'll try. But if anyone has a solution from experience or knows how to tweak this quickly, please let me know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top