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

EXCEL - ActiveSheet.PrintOut

Status
Not open for further replies.

AChiado

Programmer
Mar 1, 2002
49
IT
Hi all,

I create an excel object to automate Excel.
I can print my document with oMyExcelObject.ActiveSheet.PrintOut

but

how can I say excel what printer to use?
There is something like oMyExcelObject.ActiveSheet.SetPrinter("WindowsPrinterName")?

Now it send printer output to default printer.

Thank you all
Andrea C.P.
Italy [atom]
 
You could set your printer before your automation. With:
Code:
SET PRINTER TO NAME GETPRINTER()
** You automation starts here

Mike Gagnon
comp14.gif
 
Hi Mike,

thank you for your reply.

I try to SET PRINTER TO NAME "&cMyPrinter"

but output goes always on default printer.

Where I'm wrong? Andrea C.P.
Italy [atom]
 
AChiado

If you are going to print through automation, you either need to select the printer through the object or select the Windows printer before you instantiate the object.

Setting the printer through VFP won't have any effect as you are not printing under VFP's control. HTH

Chris [pc2]
 
AChiado

BTW, if you want a simple way to set a Windows printer download, setdefpr.exe from :-


It's a massive 24KB! [lol]

To use :-

? SET("PRINTER",3) && Vfp default printer
? SET("PRINTER",2) && Windows default printer
lcPrinter = ["WinFax"]
! /N1 setdefpr &lcPrinter
HTH

Chris [pc2]
 
Andrea

I haven't tried this, put maybe if you about it more the "Windows" way and try this code:
Code:
loComDlg = CreateObject("MSComDlg.CommonDialog")
loComDlg.ShowPrinter()

See that solves your problem.

Mike Gagnon
comp14.gif
 
Hi,

Chris, Mike, thank you

I find the solution in VBAXL9.CHM.

The EXCEL PrintOut Method can have parameters.

espressione.PrintOut(From, To, Copies, Preview, ActivePrinter
, PrintToFile, PrToFileName, Collate)

so I can set mySelectedPrinter as a parameter. It works fine

Thank you again Andrea C.P.
Italy [atom]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top