Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Printers via PrtDevNames

Status
Not open for further replies.

maxhugen

Programmer
May 25, 2004
498
AU
Does anyone know how to get a list of the Printers and drivers etc, using PrtDevNames?

I'm using types:
Code:
Type str_DEVNAMES
    RGB As String * 4
End Type
Type type_DEVNAMES
    intDriverOffset As Integer
    intDeviceOffset As Integer
    intOutputOffset As Integer
    intDefault As Integer
End Type

All I obtain from this is:

Code:
DriverOffset=8
DeviceOffset=18
OutputOffset=39
intDefault=0

MTIA


Max Hugen
Australia
 
If you are using Acc 2002 or greater, use the new printer object. This code was downloaded from MSDN:
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

All I ask is a chance to prove that money can’t make me happy.
 
Thanks, but I need to get the printer info for an A2000 application :(

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top