CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2001
    Posts
    1

    please help for this

    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!


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: please help for this

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured