• 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.

Macro sometimes not running correctly to send data to web page

I have a macro which copies selected cell value in one fixed cell and further it send that value from fixed cell to web page and hit button. But don't know why it do not run completely sometimes. It just opens IE page without adding value in textarea of web page.
Code:
Sub OpenPRdatapage()

Dim str, URL As String
Dim IE, frm As Object
Dim wb As WebBrowser
Dim objElement As Object
Dim objCollection As Object
On Error Resume Next

Selection.Copy
Range("G1").Select
ActiveSheet.Paste

str = Sheets("Hyperlink_To_PR").Range("G1").Value
URL = "https://tiweb.industrysoftware.automation.com/prdata/cgi-bin/n_prdata_index.cgi"

Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = True
IE.Navigate URL
Do
Loop While IE.Busy

    IE.Document.getElementsByName("pr_numbers")(0).Value = str
    Application.SendKeys ("~")

Call IE.Document.getElementsByTagName("button").Item(1).Click

Do
Loop While IE.Busy
Application.CutCopyMode = False
End Sub
 
Hi again :)

That has to do with the time it takes to fully load the web page.

Try:
Code:
Do Until IE.readyState = 4
DoEvents
Loop

instead of
Code:
Do
Loop While IE.Busy
 
Back
Top