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

Printing Problem 1

Status
Not open for further replies.

L0stAngel

Programmer
May 5, 2005
58
US
Hello, i've got a report that I need to print to a Remote Printer (\\Stimpson\Stiles\) without displaying the "Chose printer" dialog box. In access, you can just create a macro that does this...how can I do this in VB?
 
Use the SetDefaultPrinter API. Put this in a module:

Public Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal PrinterName As String) As Boolean

Then do this in your code where you want to print:

Dim CurrPrinterName As String
Dim NewPrinterName As String

CurrPrinterName = Printer.DeviceName
NewPrinterName = "NewPrinter'sName"

'switch to desired printer
SetDefaultPrinter NewPrinterName

'Do your printing

'switch back to original printer
SetDefaultPrinter CurrPrinterName


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thank you very much, your code is the only code i've saw that worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top