Detecting Network Printer Availability

T

Thomas M

Word 2000

I have a simple macro that prints a document to a network printer.
Last weekend the IT department did a server reorganization, and since
then we've been having problems with the availability of network
printers.

Is there a way to make the macro check the availability of a specific
network printer, and send the print job to LPT1 if the network printer is
not available?

--Tom
 
J

Jonathan West

Thomas M said:
Word 2000

I have a simple macro that prints a document to a network printer.
Last weekend the IT department did a server reorganization, and since
then we've been having problems with the availability of network
printers.

Is there a way to make the macro check the availability of a specific
network printer, and send the print job to LPT1 if the network printer is
not available?

--Tom

The following code sample lists the network printer connections

Sub ListPrinters()
Dim WshNetwork As Object
Dim oPrinters As Object
Dim i As Long

Set WshNetwork = CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
Debug.Print "Network printer mappings:"
For i = 0 To oPrinters.Count - 1 Step 2
Debug.Print "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i + 1)
Next i
End Sub

You can adapt that code to check the availability of a specific printer, by
checking whether an item in the list matches the one you want to print to.

If you want more about using Windows scripting host for these kinds of
applications, take a look here.

http://msdn.microsoft.com/library/en-us/script56/html/wsMthEnumPrinterConnections.asp
 
M

MT DOJ Help Desk

Jonathan,

Thanks for the help. I still have a problem, and I'm wondering if you can
give me some more advice. The code you posted works great for building a
list of mapped printers. However, I also need to detect if each printer is
currently *available*. We've been having problems with our network lately
and often times a printer that is mapped is not available because of a
network problem. I tried modifying the code you posted so that when it gets
the port and name for each printer, it also gets the current status, but I
wasn't able to find the commands to make that work. Do you know of any way
to get the current printer status for each mapped printer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top