Hi,
I am wondering if anyone out there knows how to detect whether a printer is installed under windows or not? Is it possible? how is it done in code? Any help is appreciated and thanx in advance.
Mike
Printable View
Hi,
I am wondering if anyone out there knows how to detect whether a printer is installed under windows or not? Is it possible? how is it done in code? Any help is appreciated and thanx in advance.
Mike
Try the code below, it works on my machine.
Im not sure if this is the best way to do it but hey, it works!!!!
Dim ConnectedPrinter As Printer
Dim NumOfPrinters As Integer
For Each ConnectedPrinter In Printers
NumOfPrinters = NumOfPrinters + 1
Next ConnectedPrinter
If NumOfPrinters = 0 Then
' NO PRINTER INSTALLED!
End If
Use the printers collection:
Alternatively, you could use the p.drivername property to see if any compatible printer is installed. Or, instead of returning true, you could Set Printer = p to make the one you found the current printer.Code:Private Function checkPrinters(strFindMe as string)
Dim p as printer
For each p in printers
If p.devicename = strFindMe then
checkPrinters = True
exit function
End if
Next p
checkPrinters = False
End function