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

Please Help...How do I programmatically change the paper tray? 3

Status
Not open for further replies.

alan232

Programmer
May 19, 2004
144
US
Problem: I have a lexmark printer connected to my network.

It can be used by:
set printer to name 'lexmark'
type (filename) to printer
However, no matter what I do, I can't get 'type' to go to the correct paper tray--it always goes to the top one.

But, if lcText = ESC+'&l4h'+chr(13)+'test message'
then:
set printer to name 'lexmark'
??? m.lcText
will print a blank line and 'test message' on the bottom tray. ESC+'&l4h' being the printer escape code.

However, this fails -- it always prints on the top tray:
set printer to name 'lexmark'
??? ESC+'&l4h'
type (printfile) to printer

I'm using visual foxpro 6. ANYHELP will be surely appreciated as my top tray has important forms which I'm sure my staff will forget to move prior to printing.

Sincerely,
Alan
 
Hi Alan

Try..
1. set printer to name 'lexmark'
??? ESC+'&l4h'+CHR(13)
type (printfile) to printer

2. If you will be sending report forms to printer, then as your first line in the report format, add the line to send.. ESC+'&l4h' as fieldbox included in the report form.
OR you may have to set that as the printers default setting and then create the report. The problem will be that you will forget that and edit the report on a later date whhich will then save the then default printer settings into the report.

3. Also if you resort to printer report header hacking as in FAQ section of the older forum, then save the tray option without clearing all the data.

:)




____________________________________________
ramani - (Subramanian.G) :)
 
Alan,

Yet another way ....

Install two printer drivers -- same printer, but different names. In one of them, set the paper tray to upper, in the other, set it to lower (or whatever it is called on your printer).

Then, to select the paper tray, just SET PRINTER TO the appropriate driver.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Hi Everyone;

Thank you all very very much.

With my type() command I am printing a text file that is built rather randomly from the 'actions' the user selects in merging two databases. I am basically using a text file to record what is being done and the changes made by various programs. (I need a hardcopy to physically make the same changes to office charts). I don't know how to make a generall enough report...form to handle all the various possibilities, so I have written a fairly simple but complete text editor to do the job. Hence, the faq on reports is great, but I'm afraid I don't think I can use it. (Unless there is a good way to use a very general report form without using records of fixed format).

I believe I tried ending the ??? ESC... with a cr, but unfortunately, type() still went to the wrong paper source.

The idea of using two different printer drivers seems easiest to do. (I'm not quite sure how windows handles printer drivers--can I use two drivers on the same port?)

Question: is there a simple API I can use? And if so, how do I call it from vfp 6 ?

Thanks again for all your help,
Sincerely,
Alan
 
hi alan

What Mike suggested is that you install the same printer what you have installed under your window os once again with a different name using the windows controlPanel->Printers-> add printer whatever depending on your OS. SO when you add the printer once again, you will be left with two different icons under your Printers options. Now, name the one with different paperTray as example.. HP-UpperTray and the other one also suitably. Now in the printers properties under Win98 or whatever OS, select the paper tray and make that as your default for that printer.

In effect, imagine you select word and print a document, if you choose the HP-UpperTray, it should print using upper Tray. Same way if you choose the other, that specific tray will be used.

Now in your VFP code, you can SET PRINTER TO [HP-UpperTray] or suitably before giving the print out command. Now you can forget about your printer codes.

But you may have to use the same printer names in other users of the software as well. But for that Mikes idea is very nice.

YOu can even overcome that as well, if you allow users to choose the printer using your code. To provide this choice, instead of using SET PRINTER TO.. you can use the code.. in one line...

SYS(1037)
then proceed to code your output.

You can see by typing in your command window.. SYS(1037) and see what you get. Users will get a chance to choose the relevant printer and select properties.

Hope this explains you sufficiently. :)



____________________________________________
ramani - (Subramanian.G) :)
 
Hi Ramani;

Thanks! I will try.

Can't let my users use sys(1037), I'm afraid they would pick the wrong printer. (I'm having a hard enough time getting them to enter the right data-which is the reason for this whole mess in the first place!)

I did try some api calls copied out of the faq area last night, they worked great. Any idea how to get the names of the ones I need to change printer trays?

Sincerely,
Alan
 
Hi All;

Just a follow-up. Having two different printer drivers in line to the same printer port was easy and great! It worked flawlessly.

It may or may not be related, but after using my test API calls (copied from the faq page), my os died. I had to rebuild the entire windows ME harddrive. I don't know if it was my test API, but I'm reluctant to try it again.

Thanks again for the great help!
Sincerely,
Alan
 
Hi All;

Me again. I just thought for those who are interested to give a follow-up on what seems the easiest approach to the printing problem: make duplicate reports.

The most straightforward approach, and the one that always seems to work, was to make the initial report the way I wanted it, then recompile it (with slightly different names) for each possible printer. Before actually printing, the program finds the correct report by matching the available printers with the saved environment setting of the report--regardless of the report name. Hence, each version of the report is specific for the tray and printer. In use, this ties up some extra disk space, but only takes a few minutes to generate as many copies of the reports as needed for all offices, printers, and trays. It may not be sleek, but it has not yet failed...yet.

Bye all and thanks again,
alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top