This is what I use, it is a variation on the printer selection ( code off the 
BWS site)

Function DownloadToFile(aFileName As String, Optional aOverWrite = True) As 
String
On Error GoTo ScriptError
   Dim w As New WinScript
   

   w.Wait 1

   w.Connect "Print Destination", stWindows
   w.Click "Print [EMAIL PROTECTED],120"  ' Select download as output.
 
   w.Key ("{TAB}" + aFileName)
   w.Enter
 
    
    'Replaced stable with this, when the system is slow, the lag can but up to 
4 seconds
    Do While Not ("Message" = View(Row:=1, Col:=1, Length:=7))
      Stable 0.5
      If "Overwrite Existing File?" = View(Row:=2, Col:=1, Length:=24) Then
        If aOverWrite Then
            Key "Y"
        Else
            Key "N"
          'Pass back error
            DownloadToFile = "Error: Output of file exists: " + aParam1
   
        End If
      End If
    Loop
    
    'wait for the report to finish
    Pause "[EMAIL PROTECTED],1"
    
    'log the result
    If At("End of [EMAIL PROTECTED],1") Then
        Logit "Report Download to: " + aParam1, lsStatus
        Enter
    
    '! Need to beef-up, but should be ok for now
    Else
        Logit "Error Downloading report to: aParam, lsError"
      'scrape the error message
        aPrintErr = Trim(View(Row:=2, Col:=1, Length:=50))  'Read error message
      'Pass back error
        DownloadToFile = "Error: " + aPrintErr
        Enter
    End If
    
Exit Function
ScriptError:
 Select Case True
   Case Err = seDoEvents
       DoEvents
       Resume
   Case Err = -2147463162
     MsgBox "SendToPrinter: Printer dialog box was not open when printer 
routine was called"
   Case Else
     MsgBox "SendToPrinter:" & Err & ": " & Error
     Exit Function
    '   If Err = seTimeOut Then End
    '   If Err = seHalt Then Exit Sub
 End Select
   
End Function


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Bob Plance
Sent: Monday, July 11, 2005 5:34 PM
To: [email protected]
Subject: [Talk] File save as prompt through BWS


BWS ers
 
I am using Meditech 5.4 and BWS. I have gotten my script file to the point 
where the dialog box opens and is asking for the name of the file (Save as).
 
I can't get the name of the file to take. I have tried using the @Dialog 
command, Key , and Enter to no avail. When I enter the file name through BWS, 
it is throwing me to the top dialog box looking for a change in folders, drive, 
etc.
 
What am I missing?
 
         Thanks all,
         Bob

Reply via email to