I'm redoing an old project was on Wordbasic with macro printings.
What I need is read my installed printers, pick the one I want to use.
I'm testing this codes example from here Retrieve installed printers list from MS.
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
and I'm getting basic errors on varies lines;
1) Dim prtloop As Printer (complie error- User-define type not defined)
2) Application.Printers (complie error- Method or data member not found)
I also saw other codes that could do this easily with "application.Printers"
For some reason my environment in Word 2016 only accept application.Printer, not application.Printers!
I know I'm failing something fundamental.
Could someone pointing me what I'm missing?