I need help for a similar macro (in fact part of it has been taken from WinblowsME). I need to send data from xcel to xtra, send the screenprint to txt and start over for x time while I have data in excel to input in xtra. In the end I expect to have a consolidated txt file where I see one screen after another. At the moment I'm only getting 1 single screen in the txt file.
Global Sys As Object
Global Sess As Object
Sub Main()
Dim outfile As String, aline As String
Dim i As Integer, iRows As Long, iCols As Long
outfile = "C:\Temp\File.txt"
Set Sys = CreateObject("Extra.System")
If Sys Is Nothing Then
MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")
Exit Sub
End If
Set Sess = Sys.ActiveSession
If Sess Is Nothing Then
MsgBox ("No session available...stopping macro playback.")
Exit Sub
End If
' ###
iRows = Sess.Screen.Rows
iCols = Sess.Screen.Cols
Dim Screen As Object
Dim system As Object
Dim Sess0 As Object
Dim Sessions As Object
Dim timeout As Integer
timeout = 500
Set system = CreateObject("EXTRA.System")
Set Screen = system.ActiveSession.Screen
Set Sessions = system.Sessions
Set Sess0 = system.ActiveSession
a = 2
valorabsoluto = Range("G" & a).Value
sucursal = Range("D" & a).Value
debehaber = Range("H" & a).Value
While valorabsoluto <> ""
'AppActivate "SAN - EXTRA! X-treme"
AppActivate "SESSION1 - EXTRA! X-treme"
SendKeys "{F9}"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "{F3}"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "82"
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "1"
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "1"
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
Sess0.Screen.WaitHostQuiet (timeout)
'íniciamos intercentro'
SendKeys "0049"
SendKeys sucursal
SendKeys "N"
SendKeys debehaber
SendKeys valorabsoluto
SendKeys "{TAB}"
Sess0.Screen.PutString "EUR", 8, 58
Sess0.Screen.PutString "719", 9, 27
Sess0.Screen.PutString "ENV.DOCUMENTACION APTE.CORRESPONDIDO POR", 10, 27
SendKeys "{TAB}"
Sess0.Screen.PutString "MMPP SIGUIENDO SUS INSTRUCCIONES", 11, 27
Sess0.Screen.PutString "ENV.DOCUMENTACION APTE.CORRESPONDIDO POR", 19, 27
SendKeys "{TAB}"
Sess0.Screen.PutString "MMPP SIGUIENDO SUS INSTRUCCIONES", 20, 27
Sess0.Screen.PutString "NO", 18, 63
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
'SELECCIONA CTA INTERNA
SendKeys "{F10}"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "{TAB}"
SendKeys "X"
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
SendKeys "~"
Sess0.Screen.WaitHostQuiet (timeout)
Open outfile For Output As #1
Do
For i = 1 To iRows
aline = UCase(Trim(Sess.Screen.GetString(i, 1, iCols)))
'MsgBox aline
Print #1, aline
Next i
a = a + 1
valorabsoluto = Range("G" & a).Value
sucursal = Range("D" & a).Value
debehaber = Range("H" & a).Value
' F8 key to skip to the next page
'Sess.Screen.SendKeys ("<Pf8>")
'Wait
' YOU'LL NEED ANOTHER CRITERIA TO STOP THE LOOP!
' If line 24 contains "LAST PAGE," stop the loop.
Loop While Trim(Sess.Screen.GetString(24, 1, iCols)) = "LAST PAGE"
Close #1
Wend
End Sub