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

comparing from excel to screen

Status
Not open for further replies.

limeg95

Programmer
Oct 22, 2009
124
CA
Hi!
i am checking against excel to screen if account matches in screen corresponding value into excel
the below code works fine, but it takes more than half an hour. is it fastest way to do that? thanks in advance


Do
For i = 2 To 3000
Account = Cells(i, "E").Text

MyScreen.MoveTo 4, 15

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" " + Account)
MyScreen.SendKeys ("<Enter>")

MyRw = MyScreen.Row

fBN = Trim(MyScreen.Getstring(MyRw, 7, 5))
LBN = Trim(MyScreen.Getstring(MyRw, 13, 5))



Cells(i, "A") = fbn
Cells(i, "B") = lbn
Next

Loop Until UCase(MyScreen.Getstring(24, 1, 10)) = "***********"
Exit Sub

 


Hi,

Unless you need the variables for stuff you'r not showing, there is no need...
Code:
    Do
        For i = 2 To 3000
            MyScreen.SendKeys ("F " & Cells(i, "E").Text)
            MyScreen.SendKeys ("<Enter>")
            
            Cells(i, "A") = Trim(MyScreen.Getstring(4, 7, 5))
            Cells(i, "B") = Trim(MyScreen.Getstring(4, 13, 5))
        Next
    
      Loop Until UCase(MyScreen.Getstring(24, 1, 10)) = "***********"
    Exit Sub
Your code leads me to believe you are coding in Excel VBA, and not Extra VB.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks a lot. but still i need one thing
if i have cell duplicate no need to check in screen but the same value write in excel how to do
 


Code:
    Dim Acct, PrevAcct
    
    Do
        For i = 2 To 3000
            Acct = Cells(i, "E").Text
            
            If PrevAcct <> Acct Then
                MyScreen.SendKeys ("F " & Cells(i, "E").Text)
                MyScreen.SendKeys ("<Enter>")
                
                Cells(i, "A") = Trim(MyScreen.Getstring(4, 7, 5))
                Cells(i, "B") = Trim(MyScreen.Getstring(4, 13, 5))
            End If
            
            PrevAcct = Acct
        Next
    
      Loop Until UCase(MyScreen.Getstring(24, 1, 10)) = "***********"

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip
iam writing the code in excel only. but the screen has 33950 lines
the excel has only 3000 lines. still find is take long time
 

but the screen has 33950 lines[/code]

what system's screen are you scraping?

Have you disclosed all the code in your Do Loop?

Do you have any system delay built into your Extra access?

Please answer ALL these questions.


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
there is no delay but do loop do i need to mention screen lines each page 6 to 24 and lines 33933. find in screen
 



Your screen has 24 lines. So how do you get 33,000+ lines? Does not compute!!!

Please include ALL your code.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
skip
again thanks a lot for your valuable time
each page has 24 lines with 4 columns
there are more than 100 pages
 


Hence the long run time.

I'd suggest shutting down Excel and reopening or even rebooting, before running.

I have a job the scrapes about 200 screens, each with 1 to 10 pages of 19 rows of data. The process begins, processing each screen in about 3 seconds but when I get to the last screens it takes about 20 seconds. Excel is know for memory leaks.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
skip
i tried today it took 25 minuts. teh screen has 600 pages.
do i get any solution. again thanks a lot for helping me
 
skip
could you please clarify
each time after find do i go to moveto 4, 15 and enter
becauase the cursor find first row and then it stands there.
need to go 4,15 and fthen find again,
 


You refuse to post your code. Therefore, I can be of no help to you.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
skip
i am not refusing
this is the whole code i provided already
Do
For i = 2 To 3000
Account = Cells(i, "E").Text

MyScreen.MoveTo 4, 15

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" " + Account)
MyScreen.SendKeys ("<Enter>")

MyRw = MyScreen.Row

fBN = Trim(MyScreen.Getstring(MyRw, 7, 5))
LBN = Trim(MyScreen.Getstring(MyRw, 13, 5))



Cells(i, "A") = fbn
Cells(i, "B") = lbn
MyScreen.MoveTo 4, 15
MyScreen.Sendkeys("<EOF>") ' clear the position

Next

Loop Until UCase(MyScreen.Getstring(24, 1, 10)) = "***********"
Exit Sub

 
this is the full code
Application.ScreenUpdating = False
Dim g_HostSettleTimE
Dim Myarea, MyArea1
Dim Myday1
Dim MyRw
Dim Sheet1 As Object
Set System = CreateObject("EXTRA.System")
Set Sess = System.ActiveSession
Set MyScreen = Sess.Screen
g_HostSettleTimE = 1000 ' milliseconds


Sess.Connected = True


If (Sess Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If


Do
For i = 2 To 3000
Account = Cells(i, "E").Text

MyScreen.MoveTo 4, 15

MyScreen.SendKeys ("F")
MyScreen.SendKeys (" " + Account)
MyScreen.SendKeys ("<Enter>")
g_HostSettleTimE
MyRw = MyScreen.Row

fBN = Trim(MyScreen.Getstring(MyRw, 7, 5))
LBN = Trim(MyScreen.Getstring(MyRw, 13, 5))

g_HostSettleTimE

Cells(i, "A") = fbn
Cells(i, "B") = lbn
MyScreen.MoveTo 4, 15
MyScreen.Sendkeys("<EOF>") ' clear the position

Next

Loop Until UCase(MyScreen.Getstring(24, 1, 10)) = "***********"
Exit Sub

 
Ski]
thanks a lot . there is a time issue, it works excellant. thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top