×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Code to search a screen for a user input

Code to search a screen for a user input

Code to search a screen for a user input

(OP)
Okay, so I have pieced together this macro from my basic understanding of them and from other existing macros. Basically, I want to be able to loop through a screen and have it find a search input that could be in Rows 8-17, from column 35-column 59, on page 1 through page 50. Pretty much I want to be able to enter 'John' in my search and have it find the JOHN in 'JOHN R SAMPLE'. Once it finds it I want to to say that it found it and ask if the macro wants to stop or continue.


Screen Sample:
FUNCTION ___ SELECT xxxxxxxx_________________ PW
08:04 03/19/13 PG 1
AKF PRC XXXXXXX XXXXX XXXXXXX SYSTEM COB 03/18/13
XXXXXXXXXXX XXXXXXXX SCREEN
TYPE1 _____ TYPE2 _____ POST/TRAN P MONTH __ STMT/CALNDR C
CHK# ________ ________ DATE 03/19/13 AMT _____________
S ST DATE TYPE TRANS AMOUNT DESCRIPTION
_ PD 03/18/13 XXXXX xxx.xx 00056949 JOHN R SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx 00056950 FRANK F SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx SAMPLE
_ PD 03/18/13 XXXXX xxxx.xx SAMPLE
_ PD 03/18/13 XXXXX xx.xx 00056820 JESSICA P PERSON
_ PD 03/18/13 XXXXX xxx.xx 00056694 JENNIFER G SMITH
_ PD 03/18/13 XXXXX xxx.xx 00057003 DOUG E DOUG
_ PD 03/18/13 XXXXX xxxx.xx 00056942 GEOFF JEFFERSON
_ PD 03/18/13 XXXX xxxx.xx SAMPLE
_ MO 03/18/13 XXXX xxxx.xx SAMPLE
<MORE>
<?>= ACTION HELP ACTION ________


What I've got:
Sub Main

Dim Sys As Object, Sess As Object, MyScreen As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

Msgtext = "Enter the ML account #"
ML_num$ = Inputbox$(Msgtext, "AKF Search"," ",125%, 100%)
MyScreen.WaitHostQuiet(50)

Msgtext = "Enter all or part of the payee name"
P_name$ = Inputbox$(Msgtext, "AKF Search"," ",125%, 100%)
MyScreen.WaitHostQuiet(50)

P_name$ = UCase(P_name$)

myscreen.sendkeys("<clear>")
MyScreen.WaitHostQuiet(10)
myscreen.sendkeys("AKF <enter>")
MyScreen.WaitHostQuiet(10)
action = myscreen.putstring(ML_num$,01,26)
MyScreen.WaitHostQuiet(10)
myscreen.sendkeys("<enter>")
MyScreen.WaitHostQuiet(10)

IsMore$ = myscreen.getstring(18,29,04)

While (IsMore$ = "MORE")

test_string$ = myscreen.getstring(ROW%,35,25)

From here out I want it to look for P_name$ within all of the test_string$ from the page and tell me if it finds it. If it doesn' then I want it to hit enter and search the next page and so on.

Any help?!?!?

RE: Code to search a screen for a user input

(OP)
Whoa, I did it.

Here is the rest of the code.

While (IsMore$ = "MORE")
ii = 0
for i = 8 to 17 step 2
ii = ii + 1

test_string$ = myscreen.getstring(i,35,25)
Pos = InStr(test_string$, PA_name$)
If pos <> 0 then
'stop here
Begin Dialog UserDialog 185, 54, "AKF Search"
Text 9, 5, 69, 20, "Item Found : Continue?"
OKButton 113,14,54, 13
CancelButton 113,33,54, 13
End Dialog
Dim mydialog as UserDialog
On Error Goto TheEnd
Dialog mydialog
MyScreen.WaitHostQuiet(10)
End if
next i
myscreen.sendkeys("<enter>")
MyScreen.WaitHostQuiet(10)
Wend

close
action = msgbox("MACRO FINISHED")
TheEnd:
End Sub

RE: Code to search a screen for a user input

very nice, thanks for posting your solution

RE: Code to search a screen for a user input

nyrtfleury14, could I bother you to look at a macro I have? I'm getting a "Type Mismatch" error and don't understand. The macro doesn't seem too technical, but can't figure out why I get the message. If you agree, I will post.

Thanks in advance.

RE: Code to search a screen for a user input

(OP)
Post away. My knowledge is pretty limited in my opinion, but I'll take a look at it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close