Changing Default Printers via VB6


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Changing Default Printers via VB6

  1. #1
    Doug Guest

    Changing Default Printers via VB6


    I need the ability to change the system default printer
    transparently to the user with VB6.

    An example of the flow would be: the user picks a report,
    VB6 changes the users default printer from "HP OfficeJet R
    Series" to "Adobe PDFWritter", VB6 calls Crystal 8.5,
    after the Crystal print job is closed VB6 sets the default
    printer back to "HP OfficeJet R Series". The code example
    below will not work because it only directs VB to a given
    printer. Crystal will still go to the systems default
    printer, in this case, the HP.

    Dim X As Printer

    For Each X In Printers
    If X.DeviceName = "Adobe PDFWritter" Then
    ' Set printer as system default.
    Set Printer = X
    ' Stop looking for a printer.
    Exit For
    End If
    Next

    thanks in advance...doug


  2. #2
    Dean Earley Guest

    Re: Changing Default Printers via VB6

    "Doug" <dougsmith@counterpoint.net> wrote in message news:3bfbb931@147.208.176.211...
    >
    > I need the ability to change the system default printer
    > transparently to the user with VB6.
    >
    > An example of the flow would be: the user picks a report,
    > VB6 changes the users default printer from "HP OfficeJet R
    > Series" to "Adobe PDFWritter", VB6 calls Crystal 8.5,
    > after the Crystal print job is closed VB6 sets the default
    > printer back to "HP OfficeJet R Series". The code example
    > below will not work because it only directs VB to a given
    > printer. Crystal will still go to the systems default
    > printer, in this case, the HP.
    >
    > Dim X As Printer
    >
    > For Each X In Printers
    > If X.DeviceName = "Adobe PDFWritter" Then
    > ' Set printer as system default.
    > Set Printer = X
    > ' Stop looking for a printer.
    > Exit For
    > End If
    > Next
    >
    > thanks in advance...doug
    >

    I'm not sure about CR8.5, but the one installed with VB6 exposes the following 3 properties.
    PrinterName
    PrinterDriver
    PrinterPort

    This is the code I have used.

    PrinterID = Settings.Printer
    If PrinterID > -1 Then
    Set Printer = Printers(PrinterID)
    End If
    Report.PrinterName = Printer.DeviceName
    Report.PrinterDriver = Printer.DriverName
    Report.PrinterPort = Printer.Port

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems



  3. #3
    Karl E. Peterson Guest

    Re: Changing Default Printers via VB6

    Hi Doug --

    > I need the ability to change the system default printer
    > transparently to the user with VB6.


    Yesterday, I uploaded a demo to my site that you'll be interested in! Grab
    PrnInfo.zip from http://www.mvps.org/vb and give it a whirl. In addition to scads of
    other stuff, it fully implements:

    ' HOWTO: Retrieve and Set the Default Printer in Windows
    ' http://support.microsoft.com/support.../q246/7/72.asp

    Later... Karl
    --
    [Microsoft Basic: 1976-2001, RIP]




  4. #4
    Michael Culley Guest

    Re: Changing Default Printers via VB6

    Doug,

    Ditch CR and go with ActiveReports, you won't be sorry

    --
    Michael Culley
    www.vbdotcom.com


    "Doug" <dougsmith@counterpoint.net> wrote in message
    news:3bfbb931@147.208.176.211...
    >
    > I need the ability to change the system default printer
    > transparently to the user with VB6.
    >
    > An example of the flow would be: the user picks a report,
    > VB6 changes the users default printer from "HP OfficeJet R
    > Series" to "Adobe PDFWritter", VB6 calls Crystal 8.5,
    > after the Crystal print job is closed VB6 sets the default
    > printer back to "HP OfficeJet R Series". The code example
    > below will not work because it only directs VB to a given
    > printer. Crystal will still go to the systems default
    > printer, in this case, the HP.
    >
    > Dim X As Printer
    >
    > For Each X In Printers
    > If X.DeviceName = "Adobe PDFWritter" Then
    > ' Set printer as system default.
    > Set Printer = X
    > ' Stop looking for a printer.
    > Exit For
    > End If
    > Next
    >
    > thanks in advance...doug
    >




  5. #5
    Norris Guest

    Re: Changing Default Printers via VB6


    See http://support.microsoft.com/support.../Q266/7/67.ASP

    "Michael Culley" <m_culley@hotmail.com> wrote:
    >Doug,
    >
    >Ditch CR and go with ActiveReports, you won't be sorry
    >
    >--
    >Michael Culley
    >www.vbdotcom.com
    >
    >
    >"Doug" <dougsmith@counterpoint.net> wrote in message
    >news:3bfbb931@147.208.176.211...
    >>
    >> I need the ability to change the system default printer
    >> transparently to the user with VB6.
    >>
    >> An example of the flow would be: the user picks a report,
    >> VB6 changes the users default printer from "HP OfficeJet R
    >> Series" to "Adobe PDFWritter", VB6 calls Crystal 8.5,
    >> after the Crystal print job is closed VB6 sets the default
    >> printer back to "HP OfficeJet R Series". The code example
    >> below will not work because it only directs VB to a given
    >> printer. Crystal will still go to the systems default
    >> printer, in this case, the HP.
    >>
    >> Dim X As Printer
    >>
    >> For Each X In Printers
    >> If X.DeviceName = "Adobe PDFWritter" Then
    >> ' Set printer as system default.
    >> Set Printer = X
    >> ' Stop looking for a printer.
    >> Exit For
    >> End If
    >> Next
    >>
    >> thanks in advance...doug
    >>

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center