• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 127
  • Last Modified:

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.
0
bemson
Asked:
bemson
  • 4
  • 2
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now