×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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

Help with Loop Extra to Excel

Help with Loop Extra to Excel

Help with Loop Extra to Excel

(OP)
Hi, I'm trying to pull numbers from an open Excel sheet (col A), Paste into an Extra (open session on correct screen), pull info back to Excel (col B), then loop to next row in column A.  The first one works...but then it doesn't loop to next.  Nothing is entered in Extra for next row.  Here is my enter code...which I copied from here:

Sub ExcelExtraExcel()

    Dim Excel As Object, ExcelWorkbook As Object
    
    Set Excel = GetObject(, "Excel.Application")
    
    Set System = CreateObject("EXTRA.System")
    
    Set Sess = System.ActiveSession
    
    Set MyScreen = Sess.Screen
    
    With Excel.Worksheets("Sheet1")
    
        Row = 1
        
        Do
        
            Pull = .Cells(Row, "A").Value  '**This will pull information from Excel
    
            MyScreen.Putstring Pull, X, X '**This will put information from Excel into Extra, use your own coordinates
            
            MyScreen.SendKeys ("<Enter>")
            MyScreen.WaitHostQuiet 100
            
            NewPull = MyScreen.Getstring(X, X, 20) '**This will pull information from Extra, use your own coordinates
            
            .Cells(Row, "B").Value = NewPull  '**This will place information from Extra to Excel
            
            Row = Row + 1  '**This will progress the code to the next line
            
        Loop Until .Cells(Row, "A").Value <> ""  '** This will loop your code until there is a blank value in Column A in Excel
        
    End With
            
End Sub
 

RE: Help with Loop Extra to Excel




Hi,

Since your are working between Excel and your emulator, I would not waste my time using Extra Basic.  It is much less robust than Excel VBA and the debugging features are better in Excel VBA as well.

Not knowing what your X value is, I can't provide much specific help.  If you were coding in Excel VBA, I'd tell you to use the Watch Window to observe the values in each statement.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Help with Loop Extra to Excel




Also, here's the technique that I've been using to wait for the cursor response, rather than a specified period of time which may be longer than necessary or too short, if the system is busy...

CODE

                .MoveRelative 1, 1, 1
                .SendKeys ("<enter>")
                Do Until (.WaitForCursor(3, 11))
                    DoEvents
                Loop
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Help with Loop Extra to Excel

i completely agree with skip on this.  If you are using excel and extra, write your code in excel vba.  If you are used to plain old VB like I was, VBA has some subtle language differences which can be difficult at first to overcome but shouldnt provide to much trouble and the VBA expressions for well know VB expressions are available all over the internet.  Also, if you arent as lucky as skip to have your return coordinates be the same every time, there is another thread on this forum called "Attachmate functions and methods help" (i think) which will provide a few other ways to 'wait for host'

just in case nobody told you, there is a bug in the WaitHostQuiet function in Extra that will essentially return the function before a new screen has been displayed and 'settled'.  that's why we keeping bringing it up :)

RE: Help with Loop Extra to Excel

(OP)
Thanks for the help!  I'm going to try adding the cursor now.  BTW, I'm using Excel for this.  

RE: Help with Loop Extra to Excel

(OP)
Still no luck.  I'm using Excel for this:

Sub ExcelExtraExcel()

    Dim Excel As Object, ExcelWorkbook As Object
    
    Set Excel = GetObject(, "Excel.Application")
    
    Set System = CreateObject("EXTRA.System")
    
    Set Sess = System.ActiveSession
    
    Set MyScreen = Sess.Screen
    
    With Excel.Worksheets("Sheet1")
    
        Row = 1
        
        Do
        
            Pull = .Cells(Row, "A").Value  '**This will pull information from Excel
    
            MyScreen.Putstring Pull, 3, 2 '**This will put information from Excel into Extra, use your own coordinates
               
            .MoveRelative 1, 1, 1
            .SendKeys ("<enter>")
            Do Until (.WaitForCursor(3, 11))
                DoEvents
            Loop
                NewPull = MyScreen.Getstring(9, 30, 20) '**This will pull information from Extra, use your own coordinates
                        
                .Cells(Row, "B").Value = NewPull  '**This will place information from Extra to Excel
            
                Row = Row + 1  '**This will progress the code to the next line
            
        Loop Until .Cells(Row, "A").Value <> ""  '** This will loop your code until there is a blank value in Column A in Excel
        
    End With
             

RE: Help with Loop Extra to Excel



"Still no luck."

Exactly WHAT does that mean?  You must be specific about what is happening, and what you expect.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Help with Loop Extra to Excel



Quote:

BTW, I'm using Excel for this.

CODE

Sub ExcelExtraExcel()
'since "I'm using Excel for this," you do not need to set the Excel application object.

    Dim Pull as string, NewPull as string, lRow as long, System as Object, Sess as object, MyScreen as object
    
    Set System = CreateObject("EXTRA.System")
    
    Set Sess = System.ActiveSession
    
    Set MyScreen = Sess.Screen
    
    With Worksheets("Sheet1")
    
        lRow = 1
        
        Do
        
            Pull = .Cells(lRow, "A").Value  '**This will pull information from Excel
    
            MyScreen.Putstring Pull, 3, 2 '**This will put information from Excel into Extra, use your own coordinates
               
            MyScreen.MoveRelative 1, 1, 1
            MyScreen.SendKeys ("<enter>")

            Do Until (MyScreen.WaitForCursor(3, 11))
                DoEvents
            Loop

            NewPull = MyScreen.Getstring(9, 30, 20) '**This will pull information from Extra, use your own coordinates
                        
            .Cells(lRow, "B").Value = NewPull  '**This will place information from Extra to Excel
            
            lRow = lRow + 1  '**This will progress the code to the next line
            
        Loop Until .Cells(lRow, "A").Value <> ""  '** This will loop your code until there is a blank value in Column A in Excel
        
    End With
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Help with Loop Extra to Excel

(OP)
I copied this exactly and when I ran it put the info from field A1 into Extra and hit enter....the screen was populated on Extra.  It did not copy the NewPull field to Excel or loop to the next one.  It only brought up the first record from the Excel list.

RE: Help with Loop Extra to Excel




Did you STEP thru your code to see what is happeneing with your objects & variables?

 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Help with Loop Extra to Excel

The problem is probably
Do Until (MyScreen.WaitForCursor(3, 11))

maybe shoud be

Do Until (MyScreen.WaitForCursor(3, 2))

 

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