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

how do I print a text file 2

Status
Not open for further replies.

GarryC

IS-IT--Management
Aug 14, 2000
36
0
0
NZ
Hi,
I have used textmerge to create a file and append to it during the course of the application. when I finish the app I print a report and the textmerge file is a descriptive summary of the process. How can I print the textmerge document? I tried TYPE - TO PRINT but I get path not found and multiple printouts of blank pages? How do I preview and then prompt for a text document?
 
GarryC

DECLARE INTEGER ShellExecute IN shell32.dll ;
[tab]INTEGER hndWin ,;
[tab]STRING lcAction ,;
[tab]STRING lcFileName ,;
[tab]STRING cParams ,;
[tab]STRING cDir ,;
[tab]INTEGER nShowWin

lcFileName = [C:\MyApp\textmerge.txt]
lcAction = [print]
ShellExecute(0 ,;
[tab]cAction ,;
[tab]cFileName ,;
[tab][] ,;
[tab][] ,;
[tab]0)


FAQ184-2483 - answering getting answered.​
Chris [pc2]
 
Apologies - typos

lcFileName = [C:\MyApp\textmerge.txt]
lcAction = [print]
ShellExecute(0 ,;
cAction ,;
cFileName ,;
[] ,;
[] ,;
0)

should be

lcFileName = [C:\MyApp\textmerge.txt]
lcAction = [print]
ShellExecute(0 ,;
lcAction ,;
lcFileName ,;
[] ,;
[] ,;
0)


FAQ184-2483 - answering getting answered.​
Chris [pc2]
 
GarryC,

Chris's method is more reliable than mine, and would probably be a better bet. However, you need to ensure that the extension of the text file (TXT in his example) is associated with an application that knows how to print it. So, TXT, DOC, etc. would be OK, but SCX for instance wouldn't be.

You also said something about previewing the file before printing. You could do that by means of Chris's code. Just change the contents of cAction from "print" to "open". That will open the file in its parent application (Notepad if it is a TXT file), from where the user can view it and optionally print it.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
GarryC

If you're going to use the code suggested by Mike to preview the file, (missed that bit [blush]), change the nShowWin parameter to 1.

A parameter of 0 would run the operation hidden so you would never get to preview the file!

FAQ184-2483 - answering getting answered.​
Chris [pc2]
 
Gary,

Depending on the amount of data and its format, you can append the data into a cursor or table and then print it using a quick VFP Report that you created. It's not much work to do this and it provides you with the ability to format the data.

Assume this is your data inside myfile.txt:
302032032Jones William 111 AnyStreet
484224424Smith Fred 222 AnyStreet
783244244Test Terry 333 AnyStreet
424244242Sample Sammy 444 AnyStreet

CREATE CURSOR myCursor (SSN C(9), Fname C(10), Lname C(10), Address C(15))

APPEND FROM myfile.txt TYPE SDF

REPORT FORM myReport NOCONSOLE TO PRINTER


Again, now you can do formatting including column headings, bold, etc. If use this more than once - it is worth the few mintues to setup the report, create the cursor, and append the data.

Cheers


Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top