Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default ++ Web automation

Hi all,

I have web interactive macro, which logs into the web.

It click serach button and result will be populated in excel but
I got one small problem here if there is no search result it will
pop window saying "no results found", then I have to click OK button
to continue the macro.
how should click ok automatically.

Please help me.

Here's the code i have used ( URL is internal )

Option Explicit
Function web_test ()
Dim ie As InternetExplorer
Dim URL As String
Dim Entid As Object, pwd As Object, form As Object
Dim pwd1 As Object, form1 As Object
Dim Fname As Object
Dim Acn As String, Acs As String
Dim Srch As Object
Dim status As Object, gender As Object, org As Object
Dim clr As Object
Dim I As Integer, Rng As Integer
Dim CID As String
Dim form2 As Object

Acn = ActiveWorkbook.Name
Acs = ActiveSheet.Name

Set ie = CreateObject("internetexplorer.application")

URL = "https://xyz.aspx "
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")

Entid.Item(0).Value = "fiorjpde"
pwd.Item(0).Value = "********"
form.Click

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

Rng = Workbooks(Acn).Sheets(Acs).Cells(Rows.Count, "A").End(xlUp).Row

For I = 2 To Rng

CID = Trim(Cells(I, "A").Value)

Set Fname = ie.Document.getelementsbyname("txtCID")
Fname.Item(0).Value = CID

Set Srch = ie.Document.getelementbyid("btnSearch")
Srch.Click

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

Set status =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgStatus")
Cells(I, "B").Value = status.innertext

Set gender =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lblGender")
Cells(I, "C").Value = gender.innertext

Set org =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgPrevOrg")
Cells(I, "d").Value = org.innertext

Set clr = ie.Document.getelementbyid("btnClear")
clr.Click

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

Next I

End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default ++ Web automation

On Dec 20, 4:44*pm, "fi.or.jp.de" wrote:
Hi all,

I have web interactive macro, which logs into the web.

It click serach button and result will be populated in excel but
I got one small problem here if there is no search result it will
pop window saying "no results found", then I have to click OK button
to continue the macro.
how should click ok automatically.

Please help me.

Here's the code i have used ( URL is internal )

Option Explicit
Function web_test ()
Dim ie As InternetExplorer
Dim URL As String
Dim Entid As Object, pwd As Object, form As Object
Dim pwd1 As Object, form1 As Object
Dim Fname As Object
Dim Acn As String, Acs As String
Dim Srch As Object
Dim status As Object, gender As Object, org As Object
Dim clr As Object
Dim I As Integer, Rng As Integer
Dim CID As String
Dim form2 As Object

Acn = ActiveWorkbook.Name
Acs = ActiveSheet.Name

Set ie = CreateObject("internetexplorer.application")

URL = "https://xyz.aspx"
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")

Entid.Item(0).Value = "fiorjpde"
pwd.Item(0).Value = "********"
form.Click

Do While ie.ReadyState < 4 Or ie.Busy = True
* *DoEvents
Loop

Rng = Workbooks(Acn).Sheets(Acs).Cells(Rows.Count, "A").End(xlUp).Row

For I = 2 To Rng

* * CID = Trim(Cells(I, "A").Value)

Set Fname = ie.Document.getelementsbyname("txtCID")
Fname.Item(0).Value = CID

Set Srch = ie.Document.getelementbyid("btnSearch")
Srch.Click

Do While ie.ReadyState < 4 Or ie.Busy = True
* * DoEvents
Loop

Set status =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgSta*tus")
Cells(I, "B").Value = status.innertext

Set gender =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lblGender*")
Cells(I, "C").Value = gender.innertext

Set org =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgPre*vOrg")
Cells(I, "d").Value = org.innertext

Set clr = ie.Document.getelementbyid("btnClear")
clr.Click

Do While ie.ReadyState < 4 Or ie.Busy = True
* *DoEvents
Loop

Next I

End Function


It's hard to say exactly what will work when you can't look at the
site, but I had the same problem when I was extracting information
from a website using an Excel macro. Sometimes when I opened the
website a pop-up window would appear, so I needed to find a way to
have the macro click the "OK' button on the pop-up if and when it
appeared. I used the following bit of code to click every button on
the webpage. From this I was able to

rr = ie.Document.all.Length - 1

For yy = 0 To rr
ie.Document.all.Item(yy).click
Next

determine which value of "yy" clicked the pop-up "OK" button. Once I
knew "yy", I was able to determine that

classname = "ui-icon ui-icon-closethick"

for the pop-up "OK" button. I also found that the phrase "Create a
price alert, free" was present in the source code only when the pop-up
window appeared. I then inserted the following code into my macro and
it was able to click the pop-up "OK" button and close the pop-up when
it appeared.

my_var = ie.Document.body.innerhtml

If instr(my_var, "Create a price alert, free", vbtext compare)1 then
rr = ie.Document.all.Length - 1

For yy = 0 To rr
If ie.Document.all.Item(yy).classname = "ui-icon ui-icon-
closethick" Then
ie.Document.all.Item(yy).Click
End If
Next
else:
end if

Perhaps something similar will work for you...ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default ++ Web automation

thanks for the reply

Its still unresolved


On Dec 21, 9:07*pm, ron wrote:
On Dec 20, 4:44*pm, "fi.or.jp.de" wrote:





Hi all,


I have web interactive macro, which logs into the web.


It click serach button and result will be populated in excel but
I got one small problem here if there is no search result it will
pop window saying "no results found", then I have to click OK button
to continue the macro.
how should click ok automatically.


Please help me.


Here's the code i have used ( URL is internal )


Option Explicit
Function web_test ()
Dim ie As InternetExplorer
Dim URL As String
Dim Entid As Object, pwd As Object, form As Object
Dim pwd1 As Object, form1 As Object
Dim Fname As Object
Dim Acn As String, Acs As String
Dim Srch As Object
Dim status As Object, gender As Object, org As Object
Dim clr As Object
Dim I As Integer, Rng As Integer
Dim CID As String
Dim form2 As Object


Acn = ActiveWorkbook.Name
Acs = ActiveSheet.Name


Set ie = CreateObject("internetexplorer.application")


URL = "https://xyz.aspx"
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")


Entid.Item(0).Value = "fiorjpde"
pwd.Item(0).Value = "********"
form.Click


Do While ie.ReadyState < 4 Or ie.Busy = True
* *DoEvents
Loop


Rng = Workbooks(Acn).Sheets(Acs).Cells(Rows.Count, "A").End(xlUp).Row


For I = 2 To Rng


* * CID = Trim(Cells(I, "A").Value)


Set Fname = ie.Document.getelementsbyname("txtCID")
Fname.Item(0).Value = CID


Set Srch = ie.Document.getelementbyid("btnSearch")
Srch.Click


Do While ie.ReadyState < 4 Or ie.Busy = True
* * DoEvents
Loop


Set status =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgSta**tus")
Cells(I, "B").Value = status.innertext


Set gender =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lblGender**")
Cells(I, "C").Value = gender.innertext


Set org =
ie.Document.getelementbyid("dtgCandidateDefaultSea rchResult_ctl03_lbldtgPre**vOrg")
Cells(I, "d").Value = org.innertext


Set clr = ie.Document.getelementbyid("btnClear")
clr.Click


Do While ie.ReadyState < 4 Or ie.Busy = True
* *DoEvents
Loop


Next I


End Function


It's hard to say exactly what will work when you can't look at the
site, but I had the same problem when I was extracting information
from a website using an Excel macro. *Sometimes when I opened the
website a pop-up window would appear, so I needed to find a way to
have the macro click the "OK' button on the pop-up if and when it
appeared. *I used the following bit of code to click every button on
the webpage. *From this I was able to

* * rr = ie.Document.all.Length - 1

* * For yy = 0 To rr
* * * * *ie.Document.all.Item(yy).click
* * Next

determine which value of "yy" clicked the pop-up "OK" button. *Once I
knew "yy", I was able to determine that

classname = "ui-icon ui-icon-closethick"

for the pop-up "OK" button. *I also found that the phrase "Create a
price alert, free" was present in the source code only when the pop-up
window appeared. *I then inserted the following code into my macro and
it was able to click the pop-up "OK" button and close the pop-up when
it appeared.

my_var = *ie.Document.body.innerhtml

If instr(my_var, "Create a price alert, free", vbtext compare)1 then
* * *rr = ie.Document.all.Length - 1

* * *For yy = 0 To rr
* * * * * * If ie.Document.all.Item(yy).classname = "ui-icon ui-icon-
closethick" Then
* * * * * * * * * * ie.Document.all.Item(yy).Click
* * * * * * End If
* * *Next
else:
end if

Perhaps something similar will work for you...ron- Hide quoted text -

- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Supressing the ctrl-c and other keys during word automation in automation apondu Excel Programming 0 July 19th 07 10:10 PM
automation Darius New Users to Excel 1 September 23rd 05 07:37 AM
Automation from VB6 Robert A. Boudra Excel Programming 2 November 16th 04 11:20 PM
about OLE automation keyur Excel Programming 0 April 5th 04 02:54 PM
Automation [email protected] Excel Programming 0 December 12th 03 02:52 PM


All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"