Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2005
    Posts
    196

    Unanswered: Call up list of installed printers

    is there any way you can have a drop down list which displays a list of the printers installed?
    For example, maybe you could have a table which lists the printers (looks at the installed printers everytime the database is opened maybe??) and you then point a combo box to this table? I could then set this as a variable to select which printer I want specific reports to come out on without having to go into the page setup for the report, cheers.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Well...I know of a couple ways you can do this...The easy way, or the harder way (just in case someone wants to know).

    The Harder Way:

    You can use some Windows API functions to carry out this task with the main call being the EnumPrinters function which is located within the WinSpool.drv library. Although more cumbersome, the API can provide a lot more information about your printers than the much easier method.

    You can see the required code located within the database module that is contained in the provided Access sample. Points of interest are of course the code module which supports all the API declarations and the function which fills the supplied Combo or List box, and the Form's OnOpen event which hold the Call to this function (FillListWithPrinters).


    The Easy Way:

    Simple....Reference the Microsoft Office 10.0 Object Library (from within your VBE) and use the Printers Object. Again, the provided Access sample shows you how. For those that want to know NOW...here it is:

    Code:
    Private Sub FillComboButton_Click()
       ' Fill the supplied control with the name of each printer
       ' First, make sure the control RowSourceType is set to Value list
    Me.myPrintersCombo.RowSourceType = "Value List"
       Dim prtLoop As Printer
       For Each prtLoop In Application.Printers
    	  Me.myPrintersCombo.RowSource = Me.myPrintersCombo.RowSource & _
    	  prtLoop.DeviceName & ";"
       Next prtLoop
    End Sub
    See the provided MS-Access sample:

    .
    Attached Files Attached Files
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Aug 2005
    Posts
    196
    cheers for that - will experiment next week.

Posting Permissions

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