Hi guys
im currently writing a piece of code that will link excel with the application I use at work, which is a terminal emulator called TN3270.
an example of my code is as follows:
Code
Sub hive()
edate = Sheet1.Range("B2").Value
bname = Sheet1.Range("C2").Value
bname = Left(bname, 17)
jno = Sheet1.Range("D2").Value
AppActivate ("Session A - tn3270")
For counter1 = 2 To 226
acolumn = "A" & counter1
polno = Sheet1.Range(acolumn).Value
SendKeys "{BREAK}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "IB01 DIS", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{TAB 2}", True
SendKeys polno, True
SendKeys "{TAB 2}", True
SendKeys "1", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{UP 2}{LEFT 31}", True
SendKeys "`````", True
SendKeys "^c", True
SendKeys "{F4}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "enter", True
SendKeys "{TAB 2}", True
SendKeys "^v", True
SendKeys "{TAB}", True
SendKeys "6", True
SendKeys "{ENTER}, true"
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "eer1", True
SendKeys edate, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{TAB 2}", True
SendKeys bname, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{F4}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "check", True
SendKeys "{TAB 3}", True
SendKeys "6", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "eer1", True
SendKeys edate, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{TAB 2}", True
SendKeys bname, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{F4}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "enter", True
SendKeys "{TAB 2}", True
SendKeys "^v", True
SendKeys "{TAB}", True
SendKeys "10", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "1", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{TAB 20}", True
SendKeys jno, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{F4}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "check", True
SendKeys "{TAB 3}", True
SendKeys "10", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "1", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
SendKeys "{TAB 20}", True
SendKeys jno, True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:01"))
Next counter1
End Sub
Display More
as you will see, theres alot of waiting going on there (almost 19 seconds in this example, which will run loop on average 150-500 times).
Im wondering, is there a way to use half a second timevalue to wait, or even better, wait on the app becoming ready?
if youve not used an emulator then its hard to explain, but when the app is busy theres a "X timer" thing at the bottom.
heres a link of someone who had a similar problem but with a differnt emulator and better explains my problem:
http://www.tek-tips.com/viewthread.cfm?qid=1088478&page=1
Thank you for your time
Jamie