RT 13 - Mismatch Using .GetElements()

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
I have added libraries in Tools References for MS Internet Controls and MS HTML Object Library. I'm trying to retrieve data from Weather Data Depot: free downloads of heating & cooling degree days. I getting a RT 13 error at the RED line below...

Rich (BB code):
Sub GrabMyData()
Dim eRow As Long
Dim ele As Object
Dim Location As Object
Dim BalancePoint
Dim BaseYear
Dim ComparisonYear
Set sht = Sheets("Output")
RowCount = 1
sht.Range("A" & RowCount) = "Location"
sht.Range("B" & RowCount) = "Base Degrees"
sht.Range("C" & RowCount) = "Base Year"
sht.Range("D" & RowCount) = "Comparison Year"

eRow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
Set objIE = CreateObject("InternetExplorer.Application")

myZipCode = Worksheets("Main").Range("B2").Value
myBalancePoint = Worksheets("Main").Range("D2").Value
myBaseYear = Worksheets("Main").Range("G2").Value
myCompYear = Worksheets("Main").Range("J2").Value

With objIE
    .Visible = True
    .navigate "http://www.weatherDataDepot.com/"
    
Do While .Busy Or _
    .readyState <> 4
DoEvents
Loop

Location = .document.getElementsByName("input_location_tab1")
Location.Item(0).Value = myZipCode

Set BalancePoint = .document.getElementsByName("selBalPoint_tab1")
BalancePoint.Item(0).Value = myBalancePoint

Set BaseYear = .document.getElementsByName("selBaseYearTab1")
BaseYear.Item(0).Value = myBaseYear

Set ComparisonYear = .document.getElementsByName("selCompYearTab1")
ComparisonYear.Item(0).Value = myCompYear

.document.getElementById("tab3CTC").Click

Do While .Busy Or _
    .readyState <> 4
DoEvents
Loop

For Each ele In .document.all

Select Case ele.classname
Case "Location"
RowCount = RowCount + 1 = ele.innertext
Case "BalancePoint"
RowCount = RowCount + 1 = ele.innertext
Case "BaseYear"
RowCount = RowCount + 1 = ele.innertext
Case "ComparisonYear"
RowCount = RowCount + 1 = ele.innertext

End Select
Next ele

End With

'Macro1

Set objIE = Nothing

End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,216,096
Messages
6,128,809
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top