• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

IE Automation Problem

Ganesh K

New Member
Hi All,

I am trying to click on the OK button we get on a prompt in the IE ( not the button on web page). I know we can use 'Application.SendKeys command to click on OK but the code just hangs in and waits for the user to click on OK before it starts executing again!

Can somebody help me here ?

Thanks in advance.
 
Do you perhaps need to add a Application.Wait in order to make sure the webpage has loaded before doing the SendKeys?
 
Hi Luke M,

Thanks for responding. Perhaps I should have posted the code earlier itself... I am using the Do While loop to ensure the page is ready. Below is the code:


Code:
Sub Att()
 
Dim ieDoc As Object
Dim SubmitBtn As Object
Dim SubmitBtn1 As Object
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.navigate ("INTERNAL TOOL" & ActiveCell)
 
Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
Loop
 
Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
   
    IE.Visible = True
Loop
 
 
IE.Document.forms(0).all("Username").Value = "username"
IE.Document.forms(0).all("Password").Value = "password"
IE.Document.forms(0).submit
 
Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
   
    IE.Visible = True
Loop
 
Set ieDoc = IE.Document
Set SubmitBtn = ieDoc.GetElementByID("submitform")
SubmitBtn.Click ' Here is the problem I am facing
 
 
'Application.SendKeys "{ENTER}"
Application.DisplayAlerts = True
 
Do While IE.readyState <> 4 Or IE.Busy = True
    DoEvents
   
    IE.Visible = True
Loop
'Application.SendKeys "{ENTER}"
Application.DisplayAlerts = True
 
End Sub



In the code above, check the text.. that is where is hangs and refuses to proceed further. Hope I am clear..

EDIT: Please use CODE tag. (DEB)
 
Back
Top