Changing the default printer

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

    Changing the default printer

    Greetings folks....

    I have a app that needs to have the printer default changed ( if not using
    the default) prior to anything else happening in the program and when the
    program terminates, to set the original default back... Any idea's?

    steve


  • Ken Tucker [MVP]

    #2
    Re: Changing the default printer

    Hi,


    Use the wmi for that. The win32_printer class has the
    setdefaultprint er method.


    ' Add a Reference to System.Manageme nt

    Dim moReturn As Management.Mana gementObjectCol lection

    Dim moSearch As Management.Mana gementObjectSea rcher

    Dim mo As Management.Mana gementObject

    moSearch = New Management.Mana gementObjectSea rcher("Select * from
    Win32_Printer")

    moReturn = moSearch.Get

    For Each mo In moReturn

    Dim strOut As String

    strOut = String.Format(" Name {0} ", mo("Name"))

    Trace.WriteLine (strOut)

    mo.InvokeMethod ("SetDefaultPri nter", Nothing)

    Next



    Ken

    ------------------------

    "Stephen" <Stephefn@xjohn stontrading.com > wrote in message
    news:uSt3sg3cEH A.3532@TK2MSFTN GP11.phx.gbl...
    Greetings folks....

    I have a app that needs to have the printer default changed ( if not using
    the default) prior to anything else happening in the program and when the
    program terminates, to set the original default back... Any idea's?

    steve



    Comment

    • Stephen

      #3
      Re: Changing the default printer

      Thank you.... I got it to work



      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
      news:e1Xmj58cEH A.1656@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Hi,
      >
      >
      > Use the wmi for that. The win32_printer class has the
      > setdefaultprint er method.
      >
      >
      > ' Add a Reference to System.Manageme nt
      >
      > Dim moReturn As Management.Mana gementObjectCol lection
      >
      > Dim moSearch As Management.Mana gementObjectSea rcher
      >
      > Dim mo As Management.Mana gementObject
      >
      > moSearch = New Management.Mana gementObjectSea rcher("Select * from
      > Win32_Printer")
      >
      > moReturn = moSearch.Get
      >
      > For Each mo In moReturn
      >
      > Dim strOut As String
      >
      > strOut = String.Format(" Name {0} ", mo("Name"))
      >
      > Trace.WriteLine (strOut)
      >
      > mo.InvokeMethod ("SetDefaultPri nter", Nothing)
      >
      > Next
      >
      >
      >
      > Ken
      >
      > ------------------------
      >
      > "Stephen" <Stephefn@xjohn stontrading.com > wrote in message
      > news:uSt3sg3cEH A.3532@TK2MSFTN GP11.phx.gbl...
      > Greetings folks....
      >
      > I have a app that needs to have the printer default changed ( if not[/color]
      using[color=blue]
      > the default) prior to anything else happening in the program and when the
      > program terminates, to set the original default back... Any idea's?
      >
      > steve
      >
      >
      >[/color]


      Comment

      Working...