Hello everyone,
I'm new to tek-tips, and VBA.
I hope to contribute in the future with some useful information. At this moment I need your precious help.
So far I have been able to extract information from attachMate based on column A (Excel) and save the result to column B(row). The method I have used assumes that for each request I get 1 back. But now I face another challenge and I do not know how to make 1 request and receive 2,3,4,5,.. information lines back to column B(row). And what I find more difficult is to detect if there is more than 1 line of results and copying them to the column B(row).
Code:
Sub fetchNP()
Set Sys = CreateObject("EXTRA.System") ' Utilizar a sessao activa Extra X-treme
Set sess = Sys.ActiveSession
Set sess = sess.screen
Dim LastRow As Long
Dim CellData As String
Dim WS1 As Worksheet
Set WS1 = Worksheets(1)
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
CellData = (WS1.Cells(i, 1).Value)
sess.SendKeys "<clear>"
sess.SendKeys "XI00"
sess.SendKeys "<ENTER>"
sess.WaitHostQuiet (0)
sess.putstring "DX.55.60.05", 23, 2, 11
sess.SendKeys "<ENTER>"
sess.SendKeys "<ENTER>"
sess.WaitHostQuiet (0)
sess.putstring CellData, 4, 20, 17
sess.putstring "12.06.2019", 4, 53, 10
sess.WaitHostQuiet (0)
sess.SendKeys "<ENTER>"
sess.WaitHostQuiet (0)
If Not sess.getstring(24, 14, 11) = "Seleccionar" Then
MsgBox "number plate error " & CellData
GoTo endM
End If
WS1.Cells(i, "B").Value = sess.getstring(9, 35, 17)
'Possible information in sess.getstring(10, 35, 17)
'Possible information in sess.getstring(11, 35, 17)
'Possible information in sess.getstring(12, 35, 17)
'And so on......
next i
endM:
End Sub