Re: Printers - How do I?

Author: Peter Cushing

Posted: 2005-03-03 at 06:46:35

Michael Savage wrote:

>A number of questions...

>

>How do I select a specific printer for a report? i.e. Let's say I want to

>print badges, on a printer that is designed for badges. However default

>reports to not print there.

>I know about set printer to name... but is there a better way as users may

>not name the same printer on the network with the same name.

>

>How do I select a special paper size i.e. 5 1/2" by 11" wide?

>

>How do I select a specific tray on a printer.. i.e. one tray may have legal

>in it the other normal... I need to select based on the report.

>

>I assume some sort of table holding the type of report, and the related

>printer would work to store the info... is this the best way to go?

>

>Does the improved report writer in VFP9 help in any of the above issues?

>

>

If you want a report to always print to a particular printer, that is

easy. You just save the information in page setup/print setup when

designing the report layout and the report will alway print to this

printer. If you want it to print to several printers, you will have to

clear out the printer information stored in the TAG TAG2 and EXPR fields

of your report. E.G mylayout.frx Open this like any table and first

record should be objtype=1 AND objcode=53, clear out these three fields

then use SET PRINTER TO NAME ... and the report will go to that name.

My code is:

SELECT 0

USE (x_home+cReportname) EXCLUSIVE

LOCATE FOR objtype=1 AND objcode=53

IF FOUND()

replace tag WITH ''

replace tag2 WITH ''

replace expr WITH 'DRIVER=Winspool' + ps_crlf + ;

'DEVICE=' + ALLTRIM(cPrinter) + ps_crlf + ;

'OUTPUT=' + ALLTRIM(prnlist.port) + ps_crlf + ;

'ORIENTATION=' + cOrientation + ps_crlf + ;

'PAPERSIZE=' + ALLTRIM(prnlist.papersize) + ps_crlf + ;

'DEFAULTSOURCE=' + ALLTRIM(prnlist.defsource) +

ps_crlf

use

ELSE

MESSAGEBOX('Could not find/update report record')

ENDIF

To get round users having different printer names on their machines, you

can set up a table of printers in your app and only allow the user to

pick printers from this table. In the above code my table is PRNLIST,

which has some defaults for each printer. These are written back to the

EXPR field.

A special papersize would go in the EXPR field above in PAPERSIZE=

To get the right setting you would set the printer up with this

papersize, then design your layout and pick this printer and save it.

Then look in the expr field to get the setting.

I assume if you pick a different tray, DEFAULTSOURCE will change, but

not tested that.

Hope that has given you some pointers

Peter

---------------------------------------------------------------

This communication and the information it contains is intended for the person or organisation to whom it is addressed.Its contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful.If you have received this message in error, please notify us immediately by telephone or email.

While Rajan Imports has taken every reasonable precaution to minimise the risk of virus transmission through email, we cannot accept liability for any damage which you sustain as a result of software viruses.

It is the responsibility of the recipient to ensure that they have adequate virus protection.

Rajan Imports Ltd

61 Great Ducie Street, Manchester M3 1RR.

Tel:0161 831 3700 Fax:0161 831 3715 www.rajan-group.co.uk

©2005 Peter Cushing