Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get HTML with VB/VBA

Status
Not open for further replies.

djRixMix

Programmer
Nov 7, 2002
12
CA
I spent a lot of time trying to find a way to do this and, after giving up, I stumbled on the solution while looking for something else...

Here it is:

'***** Begin of Code *******
'***
'***
'*** Call: a = Fetch("'***
'*** return TRUE on success
'***

Public Function Fetch(url, dest)
On Error Resume Next
Err.Clear

With CreateObject("Microsoft.XMLHTTP")
.Open "GET", url, False
.send
b = .responseBody
If Err.Number <> 0 Or .Status <> 200 Then
Fetch = False
Exit Function
End If
End With


With CreateObject("ADODB.Stream")
.Type = 1
.Open
.write b
.savetofile dest, 2
End With


Fetch = Err.Number = 0
End Function
'****** end of code *****

I hope it helps you as much as it helped me!

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top