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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for more instances of a string 2

Status
Not open for further replies.

dvirgint

Programmer
Jun 28, 2010
85
0
0
CA
Hello all,

I have information in Extra! that I need to extract. I created an Excel file to be able to manipulate the data which I will extract.

My problem is getting my macro to see more than one instance of the string I'm searching for, as it is probable there will be more than one on each page. With [blue]Sess0.Screen.Search[/blue], I cannot get it to find more than one.

I assume that I have to write the code so that the macro will search line by line to find the string? If so, can I add something at the beginning of my code to do a general search on the page for the string - if nothing is found, it changes pages - if the string is found, then it goes line by line?

I have included my code. Any suggestions?

Code:
Dim System As Object, Sess0 As Object, MyScreen As Object
Set System = CreateObject("EXTRA.System")
Set Sess0 = System.ActiveSession
Set MyScreen = Sess0.Screen
Dim i As Integer

Set tot_pages = MyScreen.area(1, 66, 1, 68)
ex_line = 2

Do       
        Set rad_find = Sess0.Screen.Search("String needed")
        If rad_find <> "String needed" Then
            Sess0.Screen.SendKeys ("<pf8>")
        Else
            rad_tax_year = Sess0.Screen.GetString(rad_find.Bottom, rad_find.Right - 17, 4)
            Sheets("Chiffres").Cells(ex_line, "a") = rad_tax_year
            If i = 12 Then
                Exit Do
            End If
        End If

        i = i + 1
    Loop Until i = tot_pages

Thanks for your help.
dvirgint
 


Code:
    Dim System As Object, Sess0 As Object, MyScreen As Object
    Set System = CreateObject("EXTRA.System")
    Set Sess0 = System.ActiveSession
    Set MyScreen = Sess0.Screen
    Dim i As Integer
    'Dim n_5 As Object
    
    
    

    Set tot_pages = MyScreen.area(1, 66, 1, 68)
    r = 1
    c = 1
    ex_line = 2
    
    Do
        
        'line_number = 5
        Set rad_find = MyScreen.Search("Radiation par", rad_find.Top + 1, 1) 'I also tried Sess0.Screen.Search
        If rad_find <> "Radiation par" Then
            Sess0.Screen.SendKeys ("<pf8>")
            Sess0.Screen.WaitHostQuiet (100)
        Else
            
            Do
                
                Set rad_find = MyScreen.Search("Radiation par", rad_find.Top + 1, 1)
                If rad_find.Top = -1 Then
                    Exit Do
                Else
                    MyScreen.MoveTo rad_find.Bottom, rad_find.Left
                    Row = MyScreen.Row
                    col = MyScreen.col
                    'MsgBox col
                    If rad_find = "Radiation par" Then
                        rad_tax_year = Sess0.Screen.GetString(rad_find.Bottom, rad_find.Right - 17, 4)
                        Sheets("Chiffres").Cells(ex_line, "a") = rad_tax_year
                        ex_line = ex_line + 1
                        MyScreen.MoveTo rad_find.Bottom, rad_find.Right
                        r = MyScreen.Row
                        c = MyScreen.col
                        'MsgBox Row
                        'MsgBox col
                        'Row = Row + 1
                    End If
                End If
                    'r = Row + 1
            Loop Until Row = 23
            Sess0.Screen.SendKeys ("<pf8>")
            r = 1
            c = 1
            Sess0.Screen.WaitHostQuiet (100)
        End If
        i = i + 1
    Loop Until i = tot_pages
 


THINK!

The code I posted was WITHIN the inner do loop, where you search.

When you INITIALLY set the search, it must have a SPECIFIC row & column or NO row or column...
Code:
    Do
        
        'line_number = 5
        Set rad_find = MyScreen.Search("Radiation par")

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 



BTW,

It is NOT necessary the cursor or use MoveTo to identiry sucessive values on the screen.

Those statements do not seem to add ANYTHING to your code, except clutter.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
[red]IT WORKS!![/red]

Thanks to both of you for your seemingly infinite patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top