Hi,
I've seen the code "Determing default printer infromation" in J Walkenbach's book.
How do i check if a pc has a printer or not?
If not, gives Msg exit sub
If yes, then do something
end sub
My simple attempt:
Sub Check_For_Printer()
Select Case Application.Activeprinter
Case 1, "" : MsgBox "No Active Printer, Check Printer Connection & Retry!", vbCritical, "No printer"
Case 2, Is <> "": do something
End Select
End Sub
Excel VBA Does Printer Exist
-
- Administrator
- Posts: 78457
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Excel VBA Does Printer Exist
I can't test whether the following version actually works - I don't have a PC without a default printer...
Keep in mind that the user can install a printer driver even if the printer is not physically present, so ActivePrinter doesn't tell you whether a printer is actually connected to the PC, only whether a printer driver has been installed and set as default.
Code: Select all
Sub Check_For_Printer()
If Application.ActivePrinter = "" Then
MsgBox "No Active Printer, Check Printer Connection & Retry!", vbCritical, "No printer"
Else
' Do something
...
End If
End Sub
Best wishes,
Hans
Hans