Re-Posting of Selecting Network Printer

I have the following code to select a printer which is part of the printer collection in the settings/printers on my NT machine,

Regardless of which printer I select the output always goes to the windows default printer in settings/printers.

Is there a vb5 conflict with windows NT or is it a vb problem?

    Dim OrigPrinter As String
    Dim SelectedPrinter As String
    Dim X As Printer
     
    SelectedPrinter = "\\EDP1\EDPHP550"
    OrigPrinter = Printer.DeviceName
     
    'Set the printer to the selected printer
    For Each X In Printers
    Debug.Print Chr$(34) & X.DeviceName & Chr$(34)
        If X.DeviceName = SelectedPrinter Then
        MsgBox X.DeviceName
        ' YES WE DO GET HERE!
            Set Printer = X
            Printer.Print "HP550"
' Prints on Default printer, why?
            Exit For
        End If
    Next

Any comments or answer appreciated.
bemsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
bemson,

In a new project, put this code in a command button and then run the program and click the button:

    For Each X In Printers
        Debug.Print "Device:" + X.DeviceName + ":"
    Next

This code will print information to the debug window.  Please copy the printed information from the debug window and then post it here.  That way, we'll know what printers we're talking about...


Cheers!
0
bemsonAuthor Commented:
FOR MCRIDER

Device:HP LaserJet 5P:
Device:Fujitsu DL 2400:
Device:\\EDP1\EDPHP550:
Device:\\BTRNTF\EDP Computer Room Laser:
Device:\\VICKILA\HP LaserJet 6P:

MY code selects printer 3 & with msgbox, we do get there! but still print to default printer
0
mcriderCommented:
Aha!

You need to read this microsoft article:

FIX: Setting Printer to Item in the Printers Collection Fails
http://support.microsoft.com/support/kb/articles/q167/7/35.asp?LNG=ENG&SA=MSDN 
 

I don't believe you have VB service pack 2 or 3 installed.  This is a known bug.  Install service pack 3 and it will go away...

Service pack 3 is available here:

http://msdn.microsoft.com/vstudio/sp/vs97/ 



Cheers!

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
by the way, don't use the "workaround solution" in that microsoft article "FIX: Setting Printer to Item in the Printers Collection Fails", just install service pack 3...


Cheers!
0
bemsonAuthor Commented:
It may take me a while to get round to installing this bug fix, so I will assume all will be ok.

Thanks for your help
0
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.