Link to home
Start Free TrialLog in
Avatar of bemson
bemson

asked on

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.
Avatar of mcrider
mcrider

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!
Avatar of bemson

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!
Avatar of bemson

ASKER

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
Thanks for the points! Glad I could help!


Cheers!