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!

Setting a Default Printer

Status
Not open for further replies.

MSW

IS-IT--Management
Jan 9, 2002
48
US
Hello; I'm trying to print a report with the following command embedded in my program..

REPORT FORM myreport.frx TO PRINT

The problem is I don't want the user to have to choose the printer. I just want the program to run and send the report to a PDF file using the ADOBE Distiller driver. It will work if I make the Adober Distiller the default printer on the system that is running the program but that's not going to work in the long run.

I'm using VFP 3.0..

Thanks..for your help..Scot
 
this FAQ by Mike may help you...

faq184-2444

Slighthaze = NULL
 
Even in VFP 3.0, the command:
SET PRINTER TO [DEFAULT | NAME WindowsPrinterName]
to change the current VFP printer works.

While we don't have SET("Printer", 3) in VFP 3/5 to grab the current printer value, I got some help and worked up the following:
Code:
*Function SetPrinter3()
* Duplicates the VFP 6.0+  SET("Printer", 3) Functionality
* i.e. It returns the Current VFP printer
*
* Thanks to Sergey Berezniker on the UT - 4/13/2002
*
* ** RGB ** changed on 04/15/02 - Added saving ALIAS()
*
LOCAL LcCursorName, lcReportName, lnLine, lcPrinterName, lcStr, lcAlias
lcAlias = ALIAS()
LcCursorName = Sys(2015)
lcReportName = Sys(2015)
SELECT 0
CREATE CURSOR (lcCursorName) ( temp C(1))
CREATE REPORT (lcReportName ) FROM (lcCursorName )
USE (lcReportName + ".FRX")
lnLine = Atline("DEVICE=", Expr)
lcStr = Mline(Expr, lnLine)
lcPrinterName = Substr( lcStr,  At("=", lcStr )+1)
USE IN (lcReportName)
ERASE (lcReportName + ".FRX")
ERASE (lcReportName + ".FRT")
IF !EMPTY(lcAlias)
   SELECT (lcAlias)
ENDIF
RETURN UPPER(lcPrinterName)

*!* EOP: SETPRINTER3.PRG
With this, you could do:
Code:
lcSaveCurrentPrinter = SetPrinter3() && save current
SET PRINTER TO NAME ADOBEDD && or whatever it's name is
REPORT FORM myreport.frx TO PRINTER
SET PRINTER TO NAME &lcSaveCurrentPrinter && reset current
Rick

 
That did the trick.....

Thanks for your help..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top