wait for an application to close

L

Laura

Good morning,

I have a module I am trying to run but it won't wait for
the application to finish going through the steps. Here is
what I have so far:
--------------------------
Option Compare Database
Option Explicit

Private Sub Upload_Yardcheck_Click()
Dim returnvalue As String
Dim temp As String
Dim strMsg As String
Dim Tasks

strMsg = "Enter your facility"
temp = InputBox(Prompt:=strMsg, Title:="Facility Name",
XPos:=2000, YPos:=2000)
returnvalue = Shell("C:\Program Files\American
Microsystems, Ltd\M5000 Utilities\m5000p.exe", 1) '
Shell M5000.
SendKeys "%c", True 'open communications menu
SendKeys "A", True ' open auto recieve.
SendKeys temp, True 'enters directory where file will be
saved.

Do Until Tasks = 0
Tasks = Tasks.Exists("m5000p")
Loop 'Until Tasks = 0
MsgBox "The application has quit."
'itrErrTrap: ' Note: This line must be left aligned.
' If Err > 0 Then MsgBox Err.Description

SendKeys "%S", True 'Save file
SendKeys "%Y", True 'Overwrite file
SendKeys "{enter}", True 'recieve file
SendKeys "{enter}", True
SendKeys "{tab}", True
SendKeys "{enter}", True
SendKeys "%{F4}", True
Exit Sub


End Sub
--------------------------------

Any thoughts anyone can offer would be greatly appreciated.

Thank you

Laura
 
G

Guest

Laura said:
Good morning,

I have a module I am trying to run but it won't wait for
the application to finish going through the steps. Here is
what I have so far:
--------------------------
Option Compare Database
Option Explicit

Private Sub Upload_Yardcheck_Click()
Dim returnvalue As String
Dim temp As String
Dim strMsg As String
Dim Tasks [snip]


Do Until Tasks = 0

^^^^^^^ Tasks has not been initialized yet. Uninitialized variables are
assigned a value of 0 by default (OK, or null, or something to that
effect). This Do loop will never be executed.

To correct, place a Tasks = 1 or Tasks = tasks.exists line before the
Do, or check out the Do ... While construction
 
T

TC

Should also put a DoEvents in that loop. Otherwise it will hog the cpu &
keep other tasks from responding.

HTH,
TC


personalIT said:
Laura said:
Good morning,

I have a module I am trying to run but it won't wait for
the application to finish going through the steps. Here is
what I have so far:
--------------------------
Option Compare Database
Option Explicit

Private Sub Upload_Yardcheck_Click()
Dim returnvalue As String
Dim temp As String
Dim strMsg As String
Dim Tasks [snip]


Do Until Tasks = 0

^^^^^^^ Tasks has not been initialized yet. Uninitialized variables are
assigned a value of 0 by default (OK, or null, or something to that
effect). This Do loop will never be executed.

To correct, place a Tasks = 1 or Tasks = tasks.exists line before the
Do, or check out the Do ... While construction

Tasks = Tasks.Exists("m5000p")
Loop 'Until Tasks = 0
MsgBox "The application has quit."
'itrErrTrap: ' Note: This line must be left aligned.
' If Err > 0 Then MsgBox Err.Description

SendKeys "%S", True 'Save file
SendKeys "%Y", True 'Overwrite file
SendKeys "{enter}", True 'recieve file
SendKeys "{enter}", True
SendKeys "{tab}", True
SendKeys "{enter}", True
SendKeys "%{F4}", True
Exit Sub


End Sub
--------------------------------

Any thoughts anyone can offer would be greatly appreciated.

Thank you

Laura
 

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