Dee0612
Thank a million. for your post....But am still confused..
sorry...
This is the script am trying to adapt for my search..So I can do the steps below....
) My problem is, am trying to write a macro thet can look for a word (B10331) on an Extra screen. (It can be anywhere on the screen)
2) If the word is on the screen copy it into an excell cell,
3) If not on the first screen, then PF8 to go to the next page,
4) However if the word cannot be found and there are no further pages, (page end at position, 23, 02) at the bottom of the screen, then write 'not found' back to excell,....
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim SearchComplete As Object
Dim MySelection
Dim MyArea As Object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
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 the default wait timeout value
g_HostSettleTime = 30 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'Check for "Prod Total" (for multiple pages) outputting each page to file
'First page
Set SearchComplete = Sess0.Screen.Search("PROD TOTAL")
If SearchComplete="" Then
Set MyArea = Sess0.Screen.Area(7,1,22,79,,2)
Else
Set MyArea = Sess0.Screen.Area(7,1,SearchComplete.Bottom,79,,2)
End If
' This section of code contains the recorded events
Sess0.Screen.Sendkeys("dcs <Tab>")
Sess0.Screen.Paste
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("dcrd<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'While loop for subsequent pages
While SearchComplete=""
Sess0.Screen.Sendkeys("<PF8>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Set SearchComplete = Sess0.Screen.Search("B10331")
Set MyArea = Sess0.Screen.Area(7,1,22,79,,2)
If SearchComplete="" Then
Set SearchComplete = Sess0.Screen.Search("NO QUEUE RECORDS")
Set MyArea = Sess0.Screen.Area(7,1,22,79,,2)
If SearchComplete="" Then
Set MyArea = Sess0.Screen.Area(7,1,22,79,,2)
Else
Set MyArea = Sess0.Screen.Area
End If
Else
Set MyArea = Sess0.Screen.Area(7,1,SearchComplete.Bottom,79,,2)
End If
Wend
End Sub