Page 1 of 1

Printing files

Posted: Fri Mar 03, 2006 7:26 pm
by chiaiese
I know it is possible to print a file using ShellExecute() but it prints to the default printer.
There is a way to redirect the print to another printer ?
I need to print various types of files to a specified printer (doc rtf pdf ecc.)

Re: Printing files

Posted: Fri Mar 03, 2006 8:17 pm
by Enrico Maria Giordano
Use SetPrintDefault() function just before calling ShellExecute().

EMG

Posted: Sat Mar 04, 2006 2:30 pm
by chiaiese
Enrico,
thanks for your answer

however I have found this other way that is simpler than setting and then restoring the default printer:

ShellExecute(0,"PrintTo",cMyDocument,"PDFCreator",0,1)

Roberto

Posted: Sat Mar 04, 2006 2:45 pm
by Enrico Maria Giordano
Wonderful!

EMG

Posted: Sun Mar 05, 2006 5:28 pm
by chiaiese
On one PC *only* I have this problem:

though I have set wordpad as the standard app to open rtf files, when I issue the ShellExecute(0,"PrintTo",cMyDoc,cMyPrinter0,0) statement, the document is printed using MsWord
If I double-click the rtf file, then WordPad is used
Normally the application used to open the file is the same that is used to print it. How can I force printing using WordPad ?

Roberto

Posted: Sun Mar 05, 2006 5:46 pm
by Enrico Maria Giordano
Check the properties of the RTF extension association. Specifically, look inside Open method. Try to compare it with those of a working PC.

EMG

Posted: Mon Mar 06, 2006 8:38 am
by chiaiese
do you mean by right-clicking the file, or something else in the windows registry (or INI file) ?

Posted: Mon Mar 06, 2006 10:38 am
by Enrico Maria Giordano
No, Tools -> Folder options -> File types (Strumenti -> Opzioni cartella -> Tipi di file in Italian).

EMG

Posted: Thu Mar 13, 2008 3:02 pm
by Ollie
ShellExecute(0,"PrintTo",cMyDocument,"MyPrinter",0,1)

works well, but it prompts the user to select the printer. Is there a way to just print directly with out the PrintSetup screen?

Posted: Mon Mar 17, 2008 8:18 am
by chiaiese
It should not prompt the user.
Check for the correct printer name as you find it in the printer folder

regards
Roberto

Posted: Fri Mar 28, 2008 3:03 pm
by Ollie
It definitely prompts the user.

I even tried:

ShellExecute( 0, "PrintTo", cHTMOut, PrnGetName() , 0, 1 )

? PrnGetName()
reports the correct name.