Thanks Skip for all your help. I'll give you a star for just trying. This is what worked. I was executing the vba code in my worksheet that had all the data. What I had to do was put the vba code in another sheet and open my original excel spreadsheet to actually get the error message copied and pasted into it. So I have an excel workbook called Execute TR Types and the original with all the TR20 transactions. I execute the code inside of TR types. Look at code below:
Public Sub Allotments20()
Dim introwcount As Integer
Dim x As Integer
Dim excelvalue As String
Set System = New ExtraSystem
' Declare variables to contain the OLE objects
Dim objExcel As Object
Dim objWorkBook As Object
Dim objChart As Object
On Error Resume Next
' Attempt to get a reference to an open instance of Excel 97
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
'If GetObject failed, open a new instance of Excel 97
Set objExcel = CreateObject("Excel.Application")
If objExcel Is Nothing Then
MsgBox ("Could not open Excel.")
Exit Sub
End If
End If
' Make Excel visible on the screen
objExcel.Visible = True
' Create a new Workbook
Set objWorkBook = objExcel.Workbooks.Open("C:\Documents and Settings\minter-kyong\My Documents\Screen Scripting Sample.xls")
If objWorkBook Is Nothing Then
MsgBox ("Could not open a new Excel workbook.")
objExcel.Quit
Exit Sub
End If
intRowCnt = Range("A1").CurrentRegion.ROWS.Count
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set Sessions = System.Sessions
If (Sessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
Set Sess0 = System.Sessions.Open("FLAIR.EDP")
Sess0.Visible = True
'Set Sess0 = System.ActiveSession
Dim move
Dim move2
Dim strL2L5 As String
Dim fieldtest
Dim strmessage
Dim result
Set MyScn = Sess0.Screen
move = MyScn.WaitForCursorMove(3)
Application.Wait (Now + TimeValue("0:00:01"))
excelvalue = Range("A1").Offset(0, 1).Value
MyScn.PutString excelvalue
MyScn.SendKeys ("<Enter>")
move2 = MyScn.WaitForCursorMove(12)
Application.Wait (Now + TimeValue("0:00:01"))
excelvalue = Range("A1").Offset(1, 1).Value
MyScn.PutString excelvalue
Sess0.Screen.MoveTo 17, 36
excelvalue = Range("A1").Offset(2, 1).Value
MyScn.PutString excelvalue
MyScn.SendKeys ("<Enter>")
move = MyScn.WaitForCursorMove(6)
Application.Wait (Now + TimeValue("0:00:01"))
MyScn.PutString "1"
MyScn.SendKeys ("<Enter>")
move2 = MyScn.WaitForCursorMove(-20)
Application.Wait (Now + TimeValue("0:00:01"))
MyScn.SendKeys ("<Enter>")
move = MyScn.WaitForCursorMove(3)
Application.Wait (Now + TimeValue("0:00:01"))
excelvalue = Range("A1").Offset(3, 1).Value
MyScn.PutString excelvalue
Sess0.Screen.MoveTo 6, 18
excelvalue = Range("A1").Offset(4, 1).Value
MyScn.PutString excelvalue
Sess0.Screen.MoveTo 6, 30
excelvalue = Range("A1").Offset(5, 1).Value
MyScn.PutString excelvalue
MyScn.SendKeys ("<Enter>")
move2 = MyScn.WaitForCursorMove(16)
Application.Wait (Now + TimeValue("0:00:01"))
MyScn.PutString "20"
Sess0.Screen.MoveTo 22, 80
MyScn.PutString "S"
MyScn.SendKeys ("<Enter>")
move = MyScn.WaitForCursorMove(-16)
Application.Wait (Now + TimeValue("0:00:01"))
excelvalue = Range("A1").Offset(9, 1).Value
strL2L5 = L2L5(excelvalue)
MyScn.PutString L2
Sess0.Screen.MoveTo 6, 8
MyScn.PutString L3
Sess0.Screen.MoveTo 6, 11
MyScn.PutString L4
Sess0.Screen.MoveTo 6, 14
MyScn.PutString L5
Sess0.Screen.MoveTo 6, 18
excelvalue = Range("A1").Offset(9, 2).Value
MyScn.PutString excelvalue
excelvalue = Range("A1").Offset(9, 3).Value
fieldtest = Value(excelvalue, 6, 21)
excelvalue = Range("A1").Offset(9, 4).Value
fieldtest = Value(excelvalue, 6, 24)
excelvalue = Range("A1").Offset(9, 5).Value
fieldtest = Value(excelvalue, 6, 31)
MyScn.SendKeys ("<Enter>")
move2 = MyScn.WaitForString("TR20S", 1, 2)
Application.Wait (Now + TimeValue("0:00:01"))
***This is the part I was having trouble with but this works now. But like I said, I had to move the vba code to another workbook for it to work.
If move2 Then
Sess0.Screen.MoveTo 1, 2
result = Sess0.Screen.GetString(1, 2, 78)
objWorkBook.Worksheets("TR20").Cells(10, 35).Value = result
Else
excelvalue = Range("A1").Offset(9, 6).Value
MyScn.PutString excelvalue
End If
'Set Sessions = Nothing
'Set System = Nothing
'Set Sess0 = Nothing
'Set MyScn = Nothing
End Sub
Thanks for the help!