Results 1 to 3 of 3

Thread: [RESOLVED] Changin the default printer

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    325

    Resolved [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")

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2008
    Posts
    325

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width