xlcior
05-09-2012, 01:12 PM
I'm trying to understand the difference between .responsetext and .document. Can someone provide an explanation?
Here are two pieces of code. The first fails and the second is successful, but I do not understand why. I feel like both should return the contents of a website, but they do not. It's strange because I have other methods that successfully use IE.document.all("text").Value to return specific information from part of a website. I guess it can't return all of the website content?
First code:
Dim IE As New InternetExplorer
IE.Visible = True
IE.navigate "website"
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim xmlHttp As Object
Dim Doc As String
xmlHttp = IE.document.Value
Doc = xmlHttp.responseText
Second code:
strURL = "website"
Set xmlHttp = CreateObject("msxml2.xmlhttp")
With xmlHttp
.Open "get", strURL, False
.send
pageText = .responseText
End With
Here are two pieces of code. The first fails and the second is successful, but I do not understand why. I feel like both should return the contents of a website, but they do not. It's strange because I have other methods that successfully use IE.document.all("text").Value to return specific information from part of a website. I guess it can't return all of the website content?
First code:
Dim IE As New InternetExplorer
IE.Visible = True
IE.navigate "website"
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim xmlHttp As Object
Dim Doc As String
xmlHttp = IE.document.Value
Doc = xmlHttp.responseText
Second code:
strURL = "website"
Set xmlHttp = CreateObject("msxml2.xmlhttp")
With xmlHttp
.Open "get", strURL, False
.send
pageText = .responseText
End With