IE Automation

F

fi.or.jp.de

Hi All,

I need some help to run my code faster. ( Excel to Web Automation )

The bloew codes logs in web site & gets the status, for the search
value mentioned in col A

I want to run for 300 hundred records, I can do loop BUT is there any
way get the results very fast. ???

Currenty It takes 40 records per minute.

Function web_test()

Set IE = New InternetExplorer

URL = confidential
IE.Visible = True

IE.Navigate URL

Do While IE.ReadyState <> 4 Or IE.Busy = True
DoEvents
Loop

Set ENTID = IE.Document.getelementsbyname("txtPersonnelNumber")
Set PWD = IE.Document.getelementsbyname("txtPassword")
Set FORM = IE.Document.getelementbyid("btnLogIn")

With login
ENTID.Item(0).Value = .username_tx
PWD.Item(0).Value = .password_tx
FORM.Click
End With

Do While IE.ReadyState <> 4 Or IE.Busy = True
DoEvents
Loop

IE.Navigate2 "Confidential 2.aspx"

Do While IE.ReadyState <> 4 Or IE.Busy = True
DoEvents
Loop

VIP = Trim(Cells(1, "a").Value)

Set FNAME = IE.Document.getelementsbyname("txtCID")
FNAME.Item(0).Value = VIP

Set SRCH = IE.Document.getelementbyid("btnSearch")
SRCH.Click

Do While IE.ReadyState <> 4 Or IE.Busy = True
DoEvents
Loop

Set ID_ID =
IE.Document.getelementbyid("dtgSearchResult_ctl03_lbldtgCID")
Cells(I, "B").Value = ID_ID.innertext

End Function
 
J

James Ravenswood

Hi All,

I need some help to run my code faster. ( Excel to Web Automation )

The bloew codes logs in web site & gets the status, for the search
value mentioned in col A

I want to run for 300 hundred records, I can do loop BUT is there any
way get the results very fast. ???

Currenty It takes 40 records per minute.

Function web_test()

Set IE = New InternetExplorer

URL = confidential
IE.Visible = True

IE.Navigate URL

Do While IE.ReadyState <> 4 Or IE.Busy = True
   DoEvents
Loop

Set ENTID = IE.Document.getelementsbyname("txtPersonnelNumber")
Set PWD = IE.Document.getelementsbyname("txtPassword")
Set FORM = IE.Document.getelementbyid("btnLogIn")

With login
    ENTID.Item(0).Value = .username_tx
    PWD.Item(0).Value = .password_tx
    FORM.Click
End With

Do While IE.ReadyState <> 4 Or IE.Busy = True
   DoEvents
Loop

IE.Navigate2 "Confidential 2.aspx"

Do While IE.ReadyState <> 4 Or IE.Busy = True
   DoEvents
Loop

VIP = Trim(Cells(1, "a").Value)

Set FNAME = IE.Document.getelementsbyname("txtCID")
    FNAME.Item(0).Value = VIP

    Set SRCH = IE.Document.getelementbyid("btnSearch")
    SRCH.Click

Do While IE.ReadyState <> 4 Or IE.Busy = True
   DoEvents
Loop

Set ID_ID =
IE.Document.getelementbyid("dtgSearchResult_ctl03_lbldtgCID")
 Cells(I, "B").Value = ID_ID.innertext

End Function

Do you need to open a new IE in the loop? Can you open it just once
and navigate in the loop?
 
F

fi.or.jp.de

Do you need to open a new IE in the loop?  Can you open it just once
and navigate in the loop?


I don't need to open new IE.
I want to loop, here's my code

For J = 1 to Cells(Rows.count,"A").end(xlup).row

VIP = Trim(Cells(J, "a").Value)

Set FNAME = IE.Document.getelementsbyname("txtCID")
FNAME.Item(0).Value = VIP

Set SRCH = IE.Document.getelementbyid("btnSearch")
SRCH.Click

Do While IE.ReadyState <> 4 Or IE.Busy = True
DoEvents
Loop

Set ID_ID =
IE.Document.getelementbyid("dtgSearchResult_ctl03_lbldtgCID")
Cells(J, "B").Value = ID_ID.innertext

Next J
 
A

AB

It might not do that much speed-wise but I'm thinking you don't need
to use the
SET element > USE element
structure. I mean, you could just use the element sraight away:

with IE.Document
..getelementsbyname("txtCID").Item(0).Value = VIP
..getelementbyid("btnSearch").Click
Cells(J, "B").Value
= .getelementbyid("dtgSearchResult_ctl03_lbldtgCID").innertext
end with
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top