Hi Gurus,
I am trying to automate an application (yeas, i am a novice!). Baiscally i need to run a software called traned from excel. The software doesnt have a com interface.

this thread is a follow up of my previous thread;
http://www.vbforums.com/showthread.p...09#post3624109


I have just 3 simple questions for you experts;

1) I am trying to use sendkeys.wait. but When i run the macros it comes up with 'compile error: Argument not optional'. If i use sendkeys only it works but its too fast! i need sendkeys to send keystrokes only when previous key strokes have finished!
2) How to terminate an application opened through shellexecute??

3) A better way to wait for the run to finish. I am using application.wait at the moment. but a better option is need due to variability in duration of runs.

I have search many forums but can't seem to find the right answer.
Please help!!

here is my code (for running the application once);
please note im using windows XP and office 07. Thanks
HTML Code:
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE = 3
Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Open_TranedFile()
 
'ShellExecute Application.hwnd, "open", "C:\Documents and Settings\naziz.EGR\Desktop\a.tnd", vbNullString, vbNullString, 1
'Application.Wait Now + TimeValue("00:00:06")
 
Dim hwndMs As Long
hwndMs = FindWindow("Afx:400000:8:10011:0:2ab0c27", vbNullString)
If hwndMs <= 0 Then MsgBox hwndMs
'MsgBox hwndMs
'Wait for application to load
 
'SetForegroundWindow (hwndMs)
Call ShowWindow(hwndMs, SW_MAXIMIZE)
 


SendKeys.SendWait "%"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{right}"
SendKeys.SendWait "{down}"
SendKeys.SendWait "~"

End Sub