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
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/")
.Send. Any idea why? (Note: I used very common URLs (google.com, youtube.com, etc. that normally have no problem to be opened programmatically.)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.
URL decoding into a String? e.g.java.net.URLDecoder.decode(url, "UTF-8");