How to determine whether a local printer is Online? (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 13:22
Joined
Jan 14, 2017
Messages
18,209
In further researching this question, I noted that perhaps you don't want to look at the printer, you want to look at the driver for the printer.


The code looks similar but you need to query the driver rather than the printer to determine status. There is a code snippet in the linked article.
Tried that. There are many properties for each printer driver of which 3 printer driver properties looked promising: StartMode, Started, Status.
Unfortunately, all 3 properties are blank for each installed printer driver on my PC

1632788010583.png
 

Isaac

Lifelong Learner
Local time
Today, 05:22
Joined
Mar 14, 2017
Messages
8,774
Not valid in Access

View attachment 94874

However, you can of course do both of these:
Code:
?Application.Printers.Count
7

?Application.Printer.DeviceName
EPSON AL-C1600

The DeviceName gives the default printer but there isn't a property to indicate whether it is switched on !
Right, you'd have to declare an Excel application instance and create it first, which is why I mentioned two lines of code rather than one.

I've discovered a lot of times in Access there have been little tricks I can do by automating Excel and because Excel is nifty at certain things, it actually ends up being less code than the access equivalent. I shouldn't say a lot of times. I should say it's happened to handful of times so it's sometimes occurs to me in situations like this.
 

isladogs

MVP / VIP
Local time
Today, 13:22
Joined
Jan 14, 2017
Messages
18,209
Right, you'd have to declare an Excel application instance and create it first, which is why I mentioned two lines of code rather than one.

I've discovered a lot of times in Access there have been little tricks I can do by automating Excel and because Excel is nifty at certain things, it actually ends up being less code than the access equivalent. I shouldn't say a lot of times. I should say it's happened to handful of times so it's sometimes occurs to me in situations like this.
Sorry I misinterpreted what you meant. However, I've since tried it in Excel

?Application.PrintCommunication returns True for me whether or not the printer is switched on.
It was still true when I physically disconnected it from the PC

The help file suggests otherwise: Application.PrintCommunication property (Excel) | Microsoft Docs
Specifies whether communication with the printer is turned on. Read/write Boolean.
 

Jason Lee Hayes

Active member
Local time
Today, 13:22
Joined
Jul 25, 2020
Messages
175
I just tried the code that @arnelgp supplied.

View attachment 94869
It correctly identifies the default printer (the only 'real' printer in the list) but reports it as 2 (unknown) whether or not it is switched on & ready to print.
I then found an item sitting in the EPSON print queue and removed it.
The printer status was then shown as 3 like all the rest whether or not it was switched on

Just wondering - has anyone checked whether those printer status values are correct? I haven't d
 

Jason Lee Hayes

Active member
Local time
Today, 13:22
Joined
Jul 25, 2020
Messages
175
Last edited:

isladogs

MVP / VIP
Local time
Today, 13:22
Joined
Jan 14, 2017
Messages
18,209
This thread has some similarities to several previous threads asking how to detect whether an Access BE is being connected using Wifi.
It is easy to determine whether a workstation has both Ethernet and Wifi connected but I've still not found a way of determining which is currently in use. For example see Solved - Confirm LAN connection. | Access World Forums (access-programmers.co.uk).

This may be a similar issue. It should be easy to do but it appears otherwise
 

Users who are viewing this thread

Top Bottom