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

Select text 2

Status
Not open for further replies.

DizzyP

Technical User
Feb 27, 2012
26
US
I have written a simple macro that searces for a string based on the user's input. If it's not found on the first page it moves to the next. It cycles through all pages until found. Sends a messages if it's found and stops on that page. It works perfectly, but I would like to have the string highlighted when it is found. I have seen this done with other macros, but I can't replicate it. I have attempted Sess0.Screen.userInput.Select and Sess0.Screen.stringFind.Select where the variables are exactly what they say they are. I get an error stating that is not such property or method. I know it's a simple snipet. Any suggestions??
 


Look for the Search Method in Extra HELP.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Code:
found = sess0.screen.select(9,15,9,20)

from the help screen
 
Thanks vz. This works for selecting certain coordinates. Now that I have the correct syntax I need to be able to turn the coordinates of the found string into a variable so it will be in the right place each time it's found. Is that possible?
 
you would need to get the coordinates of the found string, where it begins and where it ends.

how are you performing the search?
 
I'm using the serach function.
Code:
'Declare Variables
    Dim stringFind As String
    Dim userInput As String
        
'Set the user input to the string entered in the InputBox
    userInput = InputBox("What are you searching for?", "Search")
   
'Make sure that the search is started at page one
    If Sess0.Screen.GetString(3, 70, 3) <> "001" Then
        MsgBox "Please start from Page 1 "
        GoTo theend
    End If
            
'Start the search for the string
    While stringFind <> userInput
        stringFind = Sess0.Screen.Search(userInput)
        
        If stringFind = userInput Then
       [red] 'This is where the select will go [/red]
            GoTo done:
        Else
            Sess0.Screen.SendKeys ("<ENTER>")
            Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        End If
        
        If Sess0.Screen.GetString(3, 70, 3) = "001" Then
            GoTo NotFound
        End If
                    
    Wend
        
    MsgBox ("Fine! I didn't feel like searching through all that code anyway!")
    Exit Sub
    
NotFound:
    MsgBox ("Not Found!")
    Exit Sub

done:
    MsgBox ("Found It!")
    Exit Sub

theend:
End Sub
 
i guess you didn't look at the help file as Skip suggested.
 
Don't respond if your gonna be rude about it.
 
i'm sorry if you felt i was rude. you can hire a professional to help you then.
 
I did look at the help file Skip suggested. There is nothing there. The search fnction isn't referenced. And, in case you didn't look at the code I posted, I have the search portion of the code working fine.
 

ExtraHELP said:
Applies To Objects

Screen

Description

Returns an Area object with the text specified in the search.

Syntax

Set rc = object.Search(Text[,Row][,Col][,Page])

Element Description
Set The Set statement, required for assigning an object reference to a variable.
rc The object variable for referencing the returned object.
object The Screen object.
Row The row where the search begins.
Col The column where the search begins.
Page VT session only -- the screen page where the search begins.Note: This parameter is ignored for release 6.0 of EXTRA!o.
Comments

If the optional parameters are used, Screen is searched from the specified starting position. Otherwise, the entire Screen object is searched.
If Search finds the specified text, the coordinate properties (Left, Top, Right, Bottom) of the returned Area object are set to the starting and ending row and column positions of the text. The Value property of the Area object is set to the text located at those coordinates. If the Screen changes at those coordinates, the Value property of the Area changes.

If Search does not find the specified text, the Area object's Value property is set to an empty string, its Type property is set to xNONE, and its coordinate properties are set to -1.

Copyright 1996 - 1999, Attachmate Corporation. All rights reserved.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Awesome Skip! Thank you! How do I retur the coordinates rather that the text at those coordinates?
 


Returns an Area object with the text specified in the search.
The Area object contains the properties that you want.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I have tried Sess0.Screen.Select, Sess0.Screen.Area.Select, Sess0.Screen.Select(Sess0.Screen.Area) and they have all given me errors stating theat they are not valid arguments. Am I not understanding the hint?
 


Did you LOOK in Extra VB Help for the Area Object?

You seem to be GUESSING at syntax, when Extra VB Help has specific information regarding syntax.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Where is the "VB" Help? I'm not looking for you to post the answer to your previous post, I just can't find anything but Extra Help. And it contains nothing regarding VB. I'll check out the syntax online in the meantime. Thanks Skip.
 


Open the Macro Editor.

Type in Area in your code.

Select Area and hit F1.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
That just takes me to the Windows Help and Support. The same as when I choose help in the session.
 
It's because the help file is not compatible with my computer. And I don't have access to update that at work. I'm looking online for the help.
 


In the Macro Editor, don't you have a HELP in the Menu Items across the top of the window?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top