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/")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With