Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Dim obj as object
Dim objWorkbook as object
Set obj=CreateObject("Excel.Application")
Set obj = Getobject("C:\test.xls") 'i used this to test the code
set objWorkbook=obj.Worksheets("bud") 'with this worksheet
For i = 2 To obj.ActiveSheet.Rows.Count
xlData = trim(objWorkBook.Range("B" & i))
if xlData = "" Then exit For
Set MyScreen = Sess.Screen
MyScreen.PutString xlData,5,27 'this places the data from Excel
MyScreen.SendKeys ("<Enter>")
'consider pausing here to give a chance for system response
MyScreen.WaitHostQuiet (100)
MyScreen.PutString "SM", 6,48 'your code had ("SM"), this is wrong
MyScreen.SendKeys ("<Enter>")
'consider pausing here to give a chance for system response
MyScreen.WaitHostQuiet (100)
'the following code below
'moves the cursor to row 1 column one
'and then searches for the word MARKED
'if the word is found, the cursor is moved to
'where the word MARKED was found
'a comparison is made where the cursor is found
'if the cursor is still on row
'if it's not found, then go to next page
'and continue until the word is found
Do
MyScreen.MoveTo 1, 1
Set MyArea = MyScreen.Search("MARKED")
MyScreen.MoveTo MyArea.Bottom, MyArea.Left
MyRw = MyScreen.Row
If MyRw = 1 Then
MyScreen.SendKeys ("<Enter>") 'dunno how you go to next page
'change accordingly
Else
'this means MARKED was found because the cursor was moved
'from 1,1
'the following will place the word "YES"
'in column F same row as B
objWorkBook.Range("F" & i) = "YES"
exit do 'this will now loop to next entry in Excel Sheet Col B
end if
Loop
'CAUTION:
'need to exit Loop if MARKED is not found
'how many pages are there? or will MARKED always be found?
'if there are only 6 pages, then add a counter for each loop
next i
End Sub