Settings a default printer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • c_shah

    #1

    Settings a default printer

    How to change and set default printer using Visual Basic 2005
    The following works within my VB 2005 application but does any one have
    better alternative.

    /****
    Dim wshnetwork As Object = CreateObject("W Script.Network" )
    Dim printerpath As Object = "TIFF Image Printer 7.0"
    wshnetwork.SetD efaultPrinter(p rinterpath)
    **/

  • vbnetdev

    #2
    Re: Settings a default printer

    Private Sub GetMe()
    Dim a As New Printing.PageSe ttings()
    TextBox1.Text = a.PrinterSettin gs.PrinterName( )
    End Sub

    'this will get a list of every printer setup on the current machine
    Private Sub ListMe()
    Dim a As New Printing.PageSe ttings()
    Dim b As System.Drawing. Printing.Printe rSettings.Strin gCollection =
    Printing.Printe rSettings.Insta lledPrinters
    Dim X As Integer
    For X = X To b.Count - 1
    ListBox1.Items. Add(b.Item(X))
    Next
    End Sub

    'this will make the selected printer the default printer
    Private Sub ChangeMe()
    Dim a As New Printing.PageSe ttings()
    a.PrinterSettin gs.PrinterName = ListBox1.Select edItem
    End Sub

    --
    Get a powerful web, database, application, and email hosting with KJM
    Solutions




    "c_shah" <shah.chirag@ne tzero.net> wrote in message
    news:1147296473 .292215.194560@ y43g2000cwc.goo glegroups.com.. .[color=blue]
    > How to change and set default printer using Visual Basic 2005
    > The following works within my VB 2005 application but does any one have
    > better alternative.
    >
    > /****
    > Dim wshnetwork As Object = CreateObject("W Script.Network" )
    > Dim printerpath As Object = "TIFF Image Printer 7.0"
    > wshnetwork.SetD efaultPrinter(p rinterpath)
    > **/
    >[/color]


    Comment

    • c_shah

      #3
      Re: Settings a default printer

      Dim objprinter As Printing.PageSe ttings = New Printing.PageSe ttings()
      objprinter.Prin terSettings.Pri nterName = "Color Printer"

      is not changing my default printer (Black & White) to "Color Printer"

      Comment

      • c_shah

        #4
        Re: Settings a default printer

        PrinterSettings .PrinterName is not a reliable method to set a default
        printer.

        /*
        Dim wshnetwork As Object = CreateObject("W Script.Network" )
        Dim printerpath As Object = "TIFF Image Printer 7.0"
        wshnetwork.SetD efaultPrinter(p rinterpath)
        */
        but the above is not a managed code

        I found also other ways


        Comment

        • vbnetdev

          #5
          Re: Settings a default printer

          If you had wanted to change the settings of your default printer instead of
          setting the default printer itself you should have said so. However I am
          glad you found your solution.

          --
          Get a powerful web, database, application, and email hosting with KJM
          Solutions




          "c_shah" <shah.chirag@ne tzero.net> wrote in message
          news:1147354022 .700458.198170@ u72g2000cwu.goo glegroups.com.. .[color=blue]
          > PrinterSettings .PrinterName is not a reliable method to set a default
          > printer.
          >
          > /*
          > Dim wshnetwork As Object = CreateObject("W Script.Network" )
          > Dim printerpath As Object = "TIFF Image Printer 7.0"
          > wshnetwork.SetD efaultPrinter(p rinterpath)
          > */
          > but the above is not a managed code
          >
          > I found also other ways
          > http://emoreau.s2i.com/Articles/200503/EricMoreau1.html
          >[/color]


          Comment

          Working...