Friday, June 5, 2009

Listing available printers using lotus script

Listing available printers using lotus script

Dim WshNetwork As Variant
Dim WshPrinters As Variant
Dim pArray() As String
Dim iRetValue As Long
Dim DefaultPrinter As String
Dim pCount As Integer
Dim printerAvailable As Boolean
Dim n As Integer

Set WshNetwork = CreateObject("WScript.Network")
Set WshPrinters = WshNetwork.EnumPrinterConnections()

'count the connected printers
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then pCount%=pCount%+1
Next

'collect the names of the connected printers
Redim pArray(pCount%-1) As String
pCount% = 0
For n = 1 To WshPrinters.Count() Step 2
If wshPrinters(n) <> "" Then
pArray(pCount%) = wshPrinters(n)
pCount%=pCount%+1
End If
Next

No comments:

Post a Comment