×
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!
  • Students Click Here

*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

Jobs

Loop not working!

Loop not working!

Loop not working!

(OP)
Code below extracts the data for the first account # that is in column A but does not continue the loop to goto next account #. Column A has the accounts numbers and column D would be the data that is extracted from mainframe into excel


CODE -->

Sub Extract()

Dim Sessions, System As Object, Sess0 As Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession


   With Worksheets("Template")

       Row = 2
 Do

           Pull = .Cells(Row, "A").Value
           Sess0.Screen.putstring Pull, 12, 43
           Sess0.Screen.SendKeys ("<Enter>")
           Sess0.Screen.WaitHostQuiet (100)
           .Range("D1").Offset(1).Value = Trim(Sess0.Screen.GetString(7, 2, 25))
           Sess0.Screen.SendKeys ("<Clear>")
           
Exit Do

           Row = Row + 1
       Loop Until .Cells(Row, "A").Value <> ""

   End With

End Sub 

RE: Loop not working!

Hi,

Well here's what you're doing:
start loop
Assign value from Excel column A
Put that value in screen
SendKeys
Wait 100 ms regardless if the mainframe has processed the entry (which is good) 
  or NOT (which is bad, cuz you'll never get a valid value to put in Excel column D)
Put a screen value in Excel column D
Clear

EXIT THE LOOP!!!!!!!!
 

You only process the FIRST row!!!

RE: Loop not working!

(OP)
crap thats right...got it working now but one problem. The value that is extracted from Mainframe to column D keeps getting overwritten and does not move to next row

CODE -->

Sub Extract()

Dim Sessions, System As Object, Sess0 As Object

Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession

With Worksheets("Template")

Do
    For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row
           Pull = .Cells(i, "A").Value
           Sess0.Screen.putstring Pull, 12, 43
           Sess0.Screen.SendKeys ("<Enter>")
           Sess0.Screen.WaitHostQuiet (100)
           .Range("D1").Offset(1).Value = Trim(Sess0.Screen.GetString(7, 2, 25))
           Sess0.Screen.SendKeys ("<Clear>")
    Next i
Exit Do

           Row = Row + 1
       Loop Until .Cells(Row, "A").Value <> ""

   End With

End Sub 

RE: Loop not working!

(OP)
got it working now. replaced

CODE -->

.Range("D1").Offset(1).Value = Trim(Sess0.Screen.GetString(7, 2, 25)) 

to

CODE -->

.Range("D" & Rows.Count).End(xlUp).Offset(1, 0) = Trim(Sess0.Screen.GetString(7, 2, 25)) 

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