kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I have been on the web for a while now looking for solutions to my problems. I came a bit closer yet I am stacked trying to complete the next steps:
Now these are my requirements:
1. Display a msgbox alert with active or default printer name with an alert to ask user if there is a need for printer change.
2. If yes, then display the printer selection dialog box
3. Verify if the active printer has multiple trays or just a single one
4. If multiple, then ask user to select the required tray
5. Verify with msgbox alert if the selected printer is online, that is if it is connected to the pc.
Thanks in advance
Code:
Private Declare Function CreateIC Lib "gdi32" Alias "CreateICA" _
(ByVal lpDriverName As String, ByVal lpDeviceName As String, _
ByVal lpOutput As String, ByVal lpInitData As Long) As Long
Public Function GetPDC(ByVal strPrinter As String) As Long
GetPDC = CreateIC("WINSPOOL", strPrinter, vbNullString, 0&)
End Function
Sub Look_For_Printer()
'printer_name = "Name found in the print setup drop down"
printer_name = Application.ActivePrinter
If GetPDC(printer_name) = 0 Then
MsgBox "Printer name : " & Application.ActivePrinter & vbNewLine & _
"Printer status : Not found on this computer", , ""
End If
End Sub
Sub SwitchPrinter()
If MsgBox("Active printer name is : " _
& Application.ActivePrinter & vbNewLine & _
"Will you change the active printer?", vbYesNo, "") = vbYes Then
Application.Dialogs(xlDialogPrinterSetup).Show
Else
MsgBox ("The printer was not changed")
End If
End Sub
Sub ChangeTrays()
Application.SendKeys "%fu%e{TAB}{DOWN}{DOWN}{TAB}m~{ESC}", True
Application.SendKeys "%fu%e{TAB}{DOWN}{DOWN}{TAB}m~~", True
End Sub
Now these are my requirements:
1. Display a msgbox alert with active or default printer name with an alert to ask user if there is a need for printer change.
2. If yes, then display the printer selection dialog box
3. Verify if the active printer has multiple trays or just a single one
4. If multiple, then ask user to select the required tray
5. Verify with msgbox alert if the selected printer is online, that is if it is connected to the pc.
Thanks in advance