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
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
Maybe something like this?
https://learn.microsoft.com/en-us/of...alled-printers
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
You champion,
A bit of tweaking and i can print out the list now, thanks.
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
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.
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
Thanks for the replies, ill be back at work Thursday and will reply then.
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.