Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

this is the HTML code:

<table>
<tr><td>Date:</td><td><input type='text' name='d' value=''><br>(Example: Oct. 8)</td></tr>
<tr><td>Teams:</td><td><input type='text' name='away' value=''> at <input type='text' name='home' value=''><br>(Example: Florida at Buffalo)</td></tr>
<tr><td>Time:</td><td><input type='text' name='t' value=''><br>(Example: 7:00 PM)</td></tr></table><br><input type='submit' value='Submit'>"

I am using this code to:

Sub extractdata()
    Dim x As Long
    Dim objie As Object
    Set objie = CreateObject("internetexplorer.application")
    objie.Top = 0
    objie.Left = 0
    objie.Width = 800
    objie.Height = 600
    objie.Visible = True
    objie.navigate "http://www.dailynhlgoalies.com/loadSchedule.php"

    x = 1

    Dim aloha As String
    Dim aloha1 As String
    Dim aloha2 As String
    Dim aloha3 As String

     aloha = Sheet1.Range("A" & x).Value
    aloha1 = Sheet1.Range("B" & x).Value
    aloha2 = Sheet1.Range("C" & x).Value
    aloha3 = Sheet1.Range("D" & x).Value

    Application.Wait (Now + #12:00:02 AM#)

    Do
    DoEvents

    If Err.Number <> 0 Then
        objie.Quit
        Set objie = Nothing
        GoTo the_start:
    End If

    Loop Until objie.readyState = 4
        objie.document.getelementbyname("d").Value = aloha
        objie.document.getelementbyname("away").Value = aloha1
        objie.document.getelementbyname("home").Value = aloha2
        objie.document.getelementbyname("t").Value = aloha3
End Sub

but it is not working

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
331 views
Welcome To Ask or Share your Answers For Others

1 Answer

You close the application on the lines

objie.Quit
Set objie = Nothing

and try to use it later

objie.document.getelementbyname("d").Value = aloha

you get the error because you closed IE and set the pointer to Nothing

Furthermore, there is no getelementbyname, only getelementSbyname, and it returns a Collection, so you should write:

objie.document.getelementsbyname("d")(0).Value = aloha

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...