Hi,
Let me begin by thanking everyone in advance for any assistance with this macro problem. A little background: I currently have a very simple Excel macro that will send information contained in cells, one cell at a time, to another macro I have created in an AS/400 style system. The AS/400 style system will prompt for information (for example, name), and the Excel macro will send that information to the prompt, simulate Enter key (creating a new prompt in the AS/400 system), move to the next cell, send the information, etc. over and over until it reaches the last cell with information.
This works fine, however, the only way I know of "timing" the sending of information from Excel is using .Wait Now + TimeValue("0:00:01"). The issue with this is, sometimes the AS/400 system will hang after simulating Enter keystroke, but the Excel macro continues running at a single pace, resulting in some information not being sent properly. Furthermore, if Excel could send information when prompted, instead of waiting a second for each command, my process could be significantly sped up.
My question: is there some kind of way to build into the Excel macro to only send information when a valid prompt is up in the AS/400 system? I have attached a picture of the AS/400 type of prompt I'm speaking of, as well as my very simple macro to feed information to the system.
Const CA = "AS/400 System"
Const XL = "Microsoft Excel"
Sub QuickJournal()
' Quickly processes journals in (CA) window
Dim AMOUNT As String
Dim SYMBOL As String
Do Until ActiveCell = ""
SYMBOL = ActiveCell.Value
AppActivate (CA)
With Application
.Wait Now + TimeValue("0:00:01")
.SendKeys SYMBOL
.Wait Now + TimeValue("0:00:01")
.SendKeys ("~")
End With
AppActivate (XL)
ActiveCell.Offset(0, 1).Activate
AMOUNT = ActiveCell.Value
AppActivate (CA)
With Application
.Wait Now + TimeValue("0:00:01")
.SendKeys AMOUNT
.Wait Now + TimeValue("0:00:01")
.SendKeys ("~")
End With
AppActivate (XL)
ActiveCell.Offset(1, -1).Select
Loop
With Application
.Wait Now + TimeValue("0:00:01")
End With
End Sub
Again, any assistance with this question is greatly appreciated!
Bookmarks