Results 1 to 8 of 8
  1. #1
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407

    Get all current printer names


    Hi All,
    Long time not here, But now i have a need to find all the printers on my PC by full printer name.
    Has anyone done this and is there some simple code i can use to do it.

    regards
    Trevor

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    You champion,
    A bit of tweaking and i can print out the list now, thanks.

  4. #4
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    I've been away toooo long.
    Cant seem to change this from displaying the printer list in a msgbox to printing it out.
    See code below...works great, but i need to print out the list of my 7 printers
    Code:
    Sub ShowPrinters()    Dim strCount As String
        Dim strMsg As String
        Dim prtLoop As Printer
         
        On Error GoTo ShowPrinters_Err
     
        If Printers.Count > 0 Then
            ' Get count of installed printers.
            strMsg = "Printers installed: " & Printers.Count & vbCrLf & vbCrLf
         
            ' Enumerate printer system properties.
            For Each prtLoop In Application.Printers
                With prtLoop
                    strMsg = strMsg _
                        & "Device name: " & .DeviceName & vbCrLf _
                        & "Driver name: " & .DriverName & vbCrLf _
                        & "Port: " & .Port & vbCrLf & vbCrLf
                End With
            Next prtLoop
         
        Else
            strMsg = "No printers are installed."
        End If
         
        ' Display printer information.
        MsgBox Prompt:=strMsg, Buttons:=vbOKOnly, Title:="Installed Printers"
         
    ShowPrinters_End:
        Exit Sub
         
    ShowPrinters_Err:
        MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
            Title:="Error Number " & Err.Number & " Occurred"
        Resume ShowPrinters_End
         
    End Sub

  5. #5
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    What do you mean by "print out"? Text file? PDF? Spreadsheet? Something else? Regardless, I'd say that you don't want to start with strMsg being anything but an empty string. If there are no installed printers (unlikely) then outputting the leading part of the string is pointless. I'd loop through and add to the strMsg. Then if strMsg <> "" (there is at least one printer in the collection) concatenate the list to the leading part of the message, whatever that is:

    strMsg = "leading text " & strMsg

    If strMsg = "" then there are no connected printers, so don't "print out" anything. Again, what that means here needs to be explained. Maybe you want to output the strMsg to a text file? Or you can google "vba write to text file" or substitute text file to the type of output you need.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    What do you mean by "Print it out"? Print where?
    If you mean in the immediate window, replace the line
    Msgbox Prompt:=strMsg, Button....

    with
    Debug.print strMsg

  7. #7
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Thanks for the replies, ill be back at work Thursday and will reply then.

  8. #8
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    I need to print out onto paper a list of printers, i tried debug.print but that only returned the title no other information.
    How do i do it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to get printer printer options
    By darkdemon in forum Forms
    Replies: 6
    Last Post: 11-09-2020, 05:58 PM
  2. Replies: 14
    Last Post: 02-07-2020, 12:42 PM
  3. Create Table With Field Names From Current Table
    By jo15765 in forum Programming
    Replies: 5
    Last Post: 05-22-2017, 03:33 PM
  4. Print current record, open printer dialog box
    By Jamesiv1 in forum Access
    Replies: 7
    Last Post: 05-19-2014, 11:15 AM
  5. Replies: 3
    Last Post: 02-25-2014, 11:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums