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