I am currently experiencing a problem pulling some data of a web site using Excel. I have a collection of HTMLInputElement objects from which I extract the one I want. I then set the value (text) of the object and submit the form. Here is my code:
...
Dim inputElements As IHTMLElementCollection
Dim inputCounter As Integer
Dim inputETFIndex As Integer
Do
Dim etfInput As HTMLInputElement
ie.Visible = False
ie.Navigate "http://finance.yahoo.com/etf"
Do
Loop While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
Set doc = ie.document
Set inputElements = doc.getElementsByTagName("INPUT")
If Counter = 1 Then
For inputCounter = 0 To inputElements.Length - 1
Set inputele = inputElements.Item(inputCounter)
If inputele.Name = "s" And inputele.Size = 7 Then
Set etfInput = inputele
inputETFIndex = inputCounter
Exit For
End If
Next inputCounter
Else
Set etfInput = inputElements.Item(inputETFIndex)
End If
etfInput.Value = ETFSymbol
etfInput.form.submit
...
The problem is the line etfInput.Value = ETFSymbol
where I get the error message: "Object Variable or With Block Variable Not Set".
Any assistance would be greatly appreciated.
...
Dim inputElements As IHTMLElementCollection
Dim inputCounter As Integer
Dim inputETFIndex As Integer
Do
Dim etfInput As HTMLInputElement
ie.Visible = False
ie.Navigate "http://finance.yahoo.com/etf"
Do
Loop While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE
Set doc = ie.document
Set inputElements = doc.getElementsByTagName("INPUT")
If Counter = 1 Then
For inputCounter = 0 To inputElements.Length - 1
Set inputele = inputElements.Item(inputCounter)
If inputele.Name = "s" And inputele.Size = 7 Then
Set etfInput = inputele
inputETFIndex = inputCounter
Exit For
End If
Next inputCounter
Else
Set etfInput = inputElements.Item(inputETFIndex)
End If
etfInput.Value = ETFSymbol
etfInput.form.submit
...
The problem is the line etfInput.Value = ETFSymbol
where I get the error message: "Object Variable or With Block Variable Not Set".
Any assistance would be greatly appreciated.