Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search screen

Status
Not open for further replies.

ews2

Technical User
Joined
Sep 11, 2006
Messages
2
Location
US
What I need is to be able to create a macro that will search the current EXTRA screen for a word ("Letter") and move the cursor to the input field located before that word. The word will be located in a different position on the screen each time the macro is run. Can this be done?
 
Something like this would do what you want.

Code:
Dim objSys as object, objSess as object, objScreen as object
Sub Main
  Set objSys = CreateObject("EXTRA.System")
  Set objSess = objSys.ActiveSession
  Set objScreen = objSess.Screen
  sFindWord = "Letter"
  For i = 1 to objScreen.Row
    For j = 1 to objScreen.Col - Len(sFindWord)
      If objScreen.GetString(i, j, Len(sFindWord)) = sFindWord Then
        IsFound = True
        Exit For
      End If
    Next
    If IsFound Then Exit For
  Next
  'If you can tab backwards to the start of the field, this should work"
  objScreen.MoveTo i, j
  objScreen.SendKeys "+{tab}"

  'Otherwise you could do something like this:
  For j = j - 1 to 1 Step -1
    If objScreen.GetString(i, j, 1) <> " " Then Exit For
  Next
  objScreen.MoveTo i, j + 1
End Sub
 
Or
Code:
Dim objSys as object, objSess as object, objScreen as object

Sub Main
  
  Set objSys = CreateObject("EXTRA.System")
  Set objSess = objSys.ActiveSession
  Set objScreen = objSess.Screen
  sFindWord = "Letter"
  
  For i = 1 to objScreen.Row
       iFoundCol = Instr(objScreen.GetString(i, 1, 80),sFindWord) 
       If Found here <> 0 then
           objScreen.MoveTo i,iFoundCol
           objScreen.SendKeys "+{tab}"
           Exit For
       End If
  Next
End Sub

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Opps
Code:
Dim objSys as object, objSess as object, objScreen as object

Sub Main
  
  Set objSys = CreateObject("EXTRA.System")
  Set objSess = objSys.ActiveSession
  Set objScreen = objSess.Screen
  sFindWord = "Letter"
  
  For i = 1 to objScreen.Row
       iFoundCol = Instr(objScreen.GetString(i, 1, 80),sFindWord) 
       If [COLOR=red]i[/color]Found[COLOR=red]Col[/color] <> 0 then
           objScreen.MoveTo i,iFoundCol
           objScreen.SendKeys "+{tab}"
           Exit For
       End If
  Next
End Sub

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Thanks to both of you. With a little editing I got the code to work. You saved 2 hours of my day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top