[RESOLVED] Changin the default printer
In vb6, what is the proper way to select a particular printer, do a print job, and then reset the printer back to the original default? Thanks for helping me. The following command works in a vb development environment but does not work at run tme.
Code:
Dim oldprinter As String
150 oldprinter = Printer.DeviceName
Dim SetPrinter As New cSetDfltPrinter
160 Debug.Assert SetPrinter.SetPrinterAsDefault("Bullzip PDF Printer")
Re: Changin the default printer
if you just want to set a printer for your own application there is no need to change the windows default printer
if you are going to print using someother application perhaps using shellexecute, the you need to change the windows default printer while you print, then change back
you can not index the printer from its devicename, so you need to loop through all printers until the name matches
to set pritner for your application
Code:
dim p as printer
for each p in printers
if p.devicename = "Bullzip PDF Printer" then set printer = p: exit for
next
to change windows default printer do a search for setdefaultprinter API
there will be many examples
Re: Changin the default printer
I stumbled upon a solution. In the statement:
"Debug.Assert SetPrinter.SetPrinterAsDefault("Bullzip PDF Printer")"
I removed "Debug.Assert " and it started working.
It changes the printer to the pdf driver, does it's thing and resets the original default back.
By the way, this Bullzip (what a name) printer driver converts a normal print job to a pdf file which is no big deal I guess. BUT ... it is programmable. You can set the file name and even the attachment name for each email sent! In other words, if you are looping through records, it can associate a diffrent attachment for each customer, for instance. CutePDF wants $ 500 to provide the programmable version. This one is free.