Results 1 to 4 of 4

Thread: Make a printer default

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    22

    Make a printer default

    How can I make a printer default printer given its name.
    for example, "HP LaserJet MP/6". There are many printers.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Make a printer default

    It will only be the default while your program is running. Then it will revert.
    You could save the value, and set it every time your program runs, though.
    Attached Files Attached Files

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Make a printer default

    This will set the default printer permanatly.
    VB Code:
    1. ' Add a reference to the Windows Script Host Object Model
    2. Private Sub Command1_Click()
    3.     Dim wshobj As WshNetwork
    4.    
    5.     ' Create a new reference to the above-mentioned object library.
    6.     ' Call on the "SetDefaultPrinter" method to do exactly that.
    7.     Set wshobj = New WshNetwork
    8.     wshobj.SetDefaultPrinter ("PrinterNameHere")
    9.    
    10.     ' Unload the no-longer required object from the computer's memory.
    11.     Set wshobj = Nothing
    12. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Make a printer default

    Take a look at this sample (and some others that you can easily find there) by Randy Birch:
    Setting Default Printer .

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