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

Change Win Default Printer 1

Status
Not open for further replies.

CPUCurt

Programmer
Joined
Mar 19, 2002
Messages
7
Location
US
I have an application where I'm using "ShellExecute" to print a file. Of course it prints using the current Windows Default printer. I WANT to, programmaticly, change the default printer to another for this process, then change it back when it's done to the orginal default.

Does anyone have any ideas?

Thanks!
 
Use the SetDefaultPrinter API. Put this declaration in a module:

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

Or you can put it in a form, just change the declaration from Public to Private.

Just call it like so:

SetDefaultPrinter "PrinterName"

Of course, use your printer's name in place of PrinterName.

Hope this helps.



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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top