ottokyleneidert
New Member
- Joined
- Aug 21, 2014
- Messages
- 7
I have a macro that pulls data from a website-or should.
The website is: Gas Quality - Query - Chromatograph
A 424 error occurs and the line that the Debugger goes to is this one: ie.document.getElementById("frmPstDate").Value = mydate
The macro, copied and pasted here, there is more to it, but this is the section I am attempting to fix at the moment. Any help would be greatly appreciated:
Sub find_row2()
Dim ie As InternetExplorer
Dim myrow As Integer
Dim mydate As String
Dim mycell As String
myrow = 11
Set ie = New InternetExplorer
ie.Visible = False
Do
mydate = Sheets("Tuscarora").Cells(myrow, 1)
mycell = Sheets("Tuscarora").Cells(myrow, 2)
tuscarora mydate, ie
If Sheets("Data").Cells(1, 1) = "" Then
Sheets("Tuscarora").Cells(myrow, 16) = ""
Else
dereks_clean_up2 myrow
End If
If mycell <> "" Then
Exit Do
Else
myrow = myrow + 1
End If
Loop Until mydate = ""
ie.Quit
End Sub
Sub tuscarora(mydate As String, ie As InternetExplorer)
Dim url As String
Dim thelements As IHTMLElementCollection
Dim thelement As IHTMLTableCell
Dim tdelements As IHTMLElementCollection
Dim tdelement As IHTMLTableCell
url = "http://anrebb.transcanada.com/GasQuality/GQQuery.asp?sPipelineCode=TUS&sComponentType=Chromatograph"
ie.navigate (url)
While ie.Busy
DoEvents
Wend
While ie.Busy
DoEvents
Wend
ie.document.getElementById("frmPstDate").Value = mydate
ie.document.all("B1").Click
While ie.Busy
DoEvents
Wend
With Sheets("Data")
.Range("A1:ZZ500").Clear
Set thelements = ie.document.getElementsByTagName("th")
Set tdelements = ie.document.getElementsByTagName("td")
For Each thelement In thelements
.Range("A1").Offset(0, r) = thelement.innerText
r = r + 1
Next
r = 1
For Each tdelement In tdelements
.Range("A2").Offset(0, r) = tdelement.innerText
r = r + 1
Next
End With
End Sub
The website is: Gas Quality - Query - Chromatograph
A 424 error occurs and the line that the Debugger goes to is this one: ie.document.getElementById("frmPstDate").Value = mydate
The macro, copied and pasted here, there is more to it, but this is the section I am attempting to fix at the moment. Any help would be greatly appreciated:
Sub find_row2()
Dim ie As InternetExplorer
Dim myrow As Integer
Dim mydate As String
Dim mycell As String
myrow = 11
Set ie = New InternetExplorer
ie.Visible = False
Do
mydate = Sheets("Tuscarora").Cells(myrow, 1)
mycell = Sheets("Tuscarora").Cells(myrow, 2)
tuscarora mydate, ie
If Sheets("Data").Cells(1, 1) = "" Then
Sheets("Tuscarora").Cells(myrow, 16) = ""
Else
dereks_clean_up2 myrow
End If
If mycell <> "" Then
Exit Do
Else
myrow = myrow + 1
End If
Loop Until mydate = ""
ie.Quit
End Sub
Sub tuscarora(mydate As String, ie As InternetExplorer)
Dim url As String
Dim thelements As IHTMLElementCollection
Dim thelement As IHTMLTableCell
Dim tdelements As IHTMLElementCollection
Dim tdelement As IHTMLTableCell
url = "http://anrebb.transcanada.com/GasQuality/GQQuery.asp?sPipelineCode=TUS&sComponentType=Chromatograph"
ie.navigate (url)
While ie.Busy
DoEvents
Wend
While ie.Busy
DoEvents
Wend
ie.document.getElementById("frmPstDate").Value = mydate
ie.document.all("B1").Click
While ie.Busy
DoEvents
Wend
With Sheets("Data")
.Range("A1:ZZ500").Clear
Set thelements = ie.document.getElementsByTagName("th")
Set tdelements = ie.document.getElementsByTagName("td")
For Each thelement In thelements
.Range("A1").Offset(0, r) = thelement.innerText
r = r + 1
Next
r = 1
For Each tdelement In tdelements
.Range("A2").Offset(0, r) = tdelement.innerText
r = r + 1
Next
End With
End Sub