Hi,
I need to bring data which is displayed as a single line of text from
a website into VBA for processing. Is there an easy way to do this?
Public Function GetHTML(ByVal sURL As String) _
As String
Dim xmlhttp As Object
Dim sResponse As String, _
sSeek As string
Dim v As Long, _
n As long
Set xmlhttp = CreateObject("Msxml2.XMLHTTP")
xmlhttp.Open "GET", sURL, False
xmlhttp.send
sResponse = xmlhttp.responseText
Set xmlhttp = Nothing
'Parse HTML-Cde...
v = InStr(1, sresponse, "<body", vbDatabaseCompare)
If v > 0 Then
sSeek = Mid(sresponse, v + 6)
End If
n = InStr(1, sSeek, "</body>", vbTextCompare)
If n > 0 Then
GetHTML = Left(sSeek, n - 1)
End If
End Function
You'll still have to add a error handling.