Click to See Complete Forum and Search --> : please help for this


skyoda
July 12th, 2001, 02:45 PM
Hi!

I need to get a list of all installed printer
via Microsoft Acces for windows...
I must do that in VBA code source.
How can I do that?

Thank you very much!

Iouri
July 12th, 2001, 02:54 PM
Public Function PopulateListControlWithPrinters(ListControl As _
Object) As Boolean

On Error GoTo errHandler:
Dim l As Long
Dim lCount As Long
ListControl.Clear

lCount = Printers.Count
If lCount = 0 Then
ListControl.AddItem "(No Printer Installed)"
Else
For l = 0 To lCount - 1
ListControl.AddItem Printers(l).DeviceName
Next
End If

PopulateListControlWithPrinters = True
Exit Function

errHandler:
PopulateListControlWithPrinters = False
Exit Function

End Function

'==============================================================

'another way

private Sub Form_Load()
Combo1.Clear
m_GetPrinters Combo1
Combo1.ListIndex = 0
End Sub

'----------------------------------------------------------------------------------
' looking for all printers and filling objListOrCombo
'----------------------------------------------------------------------------------
public Sub m_GetPrinters(byref objListOrCombo as Object)
Dim objPrinter as Printer
Dim intNbOfPrinters as Integer

intNbOfPrinters = Printers.Count - 1
for Each objPrinter In Printers
objListOrCombo.AddItem objPrinter.DeviceName
next
End Sub







Iouri Boutchkine
iouri@hotsheet.com