Hi All,

I ahve been tryhing to get the SelectPrinter script from the BOSSOFT.com site to work correctly. So far it seem so pick the wrong printer, some times the one above, some times the one below. I am not trying for the first or last printer in the list, but there are about 20 printers to choose from.

Any ideas would be great.

Thanks

Sub SelectPrinter(ByVal Printer As String)
    Dim i As Integer
    Dim PrinterPos As Integer
    Dim SelectPos As Integer
    Dim t$
    Dim Dif As Integer
    Dim W As New WinScript

    Wait 1
   
    W.Connect "Print Destination", stWindows
    W.Activate "Print Destination"
    W.Click "Print [EMAIL PROTECTED],72"
    i = 1
    PrinterPos = 0
    SelectPos = 0

    While PrinterPos = 0 Or SelectPos = 0
        t$ = Trim(W.View(Window:="Print [EMAIL PROTECTED],84", Row:=i, col:=1, length:=30, b:=bcComboBoxAll))
        If InStr(t$, "-->") <> 0 Then SelectPos = i
        If InStr(t$, Printer) <> 0 Then PrinterPos = i
        DoEvents
        i = i + 1
   Wend
    W.Click "Print [EMAIL PROTECTED],84"
    Dif = SelectPos - PrinterPos
    If Dif > 0 Then
        For i = 1 To Dif
            W.Key "{UP}"
        Next i
    ElseIf Dif < 0 Then
        Dif = 0 - Dif
        For i = 1 To Dif
            W.Key "{DOWN}"
        Next i
    End If
    Wait 0.5
    W.Key "{TAB}"
End Sub

Bruce Krigman
Information Systems
South Shore Hospital
781-340-8299

Reply via email to