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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing files with foxpro 8

Status
Not open for further replies.

ExtraD

Programmer
Jul 6, 2005
41
NL
Hi,

I think its an simple question but i can't find the answer.
How do i print a file (no report) from within foxpro with no printer selection screen to the default windows printer.

I found some shell examples but then i get the printer selection screen and i just need it to be printed on the windows default printer.

Thanx in advance,
 

What sort of file are you talking about? A text file? A DBF?

Assuming you mean a text file, one possibility would be:

Code:
SET PRINTER ON
lcVar = FILETOSTR("MyFile.txt")
? lcVar
SET PRINTER OFF

There are several other ways as well.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
sorry forgot to mention its a .htm file.
so i can't print the text, itselve.
 

Well, you could print the file in the way I showed, but it would include all the HTML tags. If that's not what you want, there is other solutions, but they are more complicated.

One option would be to add a web browser control to a form. Use the control's Navigate2 method to open the HTML file. Then call its ExecWB method to print.

ExecWB takes two parameters. The first is 6, which just means you want to print. The second is 1 if you want to display the print dialogue, or 2 if you want to print straight to the Windows default printer.

If you want to follow this approach, check the documentation for the web browser control. It should tell you what you need to know.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Actually, I've just thought of a simpler way:

Code:
DECLARE INTEGER ShellExecute IN shell32.dll ;
	INTEGER hndWin, ;
	STRING cAction, ;
	STRING cFileName, ;
	STRING cParams, ;
	STRING cDir, ;
	INTEGER nShowWin

lcFile = "c:\data\myfile.htm"
? ShellExecute(0,"print",lcFile,"","",1)


Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike

Your simpler way does bring up the printer selection screen.

ExtraD

Another way would be to create an instance of IE, navigate to the file, and print it.

There is no need for the IE object to be visible.

Then close the IE object and release the object reference.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommandertm.net
PDFcommandertm.com
 
Thanx, for the great solution.
I'm using the activeX control with the property!
Works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top