Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read content of network printer folder

Status
Not open for further replies.

data59

MIS
Jun 30, 2005
17
0
0
US
I have been looking for an answer to this question for a few weeks. It seems like it should be easy but so far no luck. I would like to be able to read the content of a network folder containing available printers in to a combo or list box.
The way our structure is set up we have hundreds of printers so to find a network printer you first have to know what server its on. It could be on one of 50 or so different servers. Generally what you do is go to Run type the server name i.e. \\priter location –typ- number (\\b-1-bw-lexmark-675) then double click on the printer you want so it adds it to your local list. What I’m trying to do is allow the user to open the network folder containing available printers and save the printer they choose to a DB. The DB will allow them to assign an associative name that means something to them. Such as “printer in b-12 near coffee machine”. I have all the coding I need except for how to read the network printer server file for the friendly names of the printers. Hope this makes sense. Also I’m just getting started in using VB6 so I may not have all the correct terminology when trying to explain my goal. Thanks for helping.
 
Hi, you can use something like this to read the contents of file folders:

Private Sub cboFiles_Enter()

Dim myFile, Stsql As String

myFile = Dir("C:\Temp\*.*")
Stsql = myFile & ";"

Do While Not (myFile = "")

myFile = Dir

If myFile = "" Then
Stsql = Stsql

Else:

Stsql = Stsql & myFile & ";"

End If

Loop


Me.CboFiles.RowSource = Stsql

End Sub

Set the combo or list box rowsource type to Value List.

Select the printer from the combo box and then provide another field for the user friendly name.

Is that what you had in mind?


 
Thanks for the replay, but I’m not sure how this would work? How does it make the connection to the network? What I want to do is populate an unbound combo box with the list of network printers available on a given drive. This has been the toughest problem I have come across when intuitively it seems, as it should be simple. I didn’t think it possible but this one may not be doable. Again I really appreciate your help I’m new to VB6 and love to learn.
 
I'd look at the EnumPrinters API, which will list all printers on a specific domain, server or print provider...

Enumerate the printers using PRINTER_INFO_4 and you will have the essence of your solution.

Thread222-671023 gives some useful code, or search this forum for EnumeratePrinters

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top