Reputation: 105
i want to read the HTML code in VBA (something like URL in Java). I need to save it in a string. I parse it afterwards.
alpan67
Upvotes: 2
Views: 28811
Reputation: 13122
Here's a function for you. It will return the String of the HTML returned by a given URL.
Function GetHTML(URL As String) As String
Dim HTML As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
.Send
GetHTML = .ResponseText
End With
End Function
Just make sure your provided URL is well formed. I.E. it includes the http://
or https://
if appropriate.
For Example: GetHtml("www.google.com")
is incorrect.
You would want GetHtml("https://www.google.com/")
Upvotes: 10
Reputation: 14361
To do the URL DECODING you may use that post as a reference.
Here goes a article that uses MS Word to save html of web page as text.
Code in Excel VBA - from VBAExpress: I wouldn't fancy copying his code. You may give it a try and comment.
Upvotes: 0