'add references to
microsoft scripting runtime
microsoft internet controls
ms ado
ms msxml
ms HTML object library
watch out for wrapping.
Tim.
______________________________________________________________
Option Explicit
Sub tester()
GetFiles
"
http://www.irs.gov/taxpros/providers/article/0,,id=109942,00.html", ".xls"
End Sub
Sub GetFiles(sURL As String, sExtension As String)
Dim oDoc As New MSHTML.HTMLDocument
Dim iCount As Integer
Dim IE As New InternetExplorer
Dim i As Integer
IE.navigate sURL
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
Set oDoc = IE.Document
iCount = 0
For i = 1 To oDoc.links.Length
If oDoc.links(i - 1).href Like "*" & sExtension Then
'MsgBox oDoc.links(i - 1).href & "(" & oDoc.links(i - 1).innerHTML
& ")"
saveFile oDoc.links(i - 1).href, _
ThisWorkbook.Path & "\" & oDoc.links(i - 1).innerHTML &
".xls"
End If
iCount = iCount + 1
If iCount > 3 Then Exit For 'comment out for production
Next i
Set oDoc = Nothing
Set IE = Nothing
Application.StatusBar = False
End Sub
Sub saveFile(sURL As String, sPath As String)
Dim oXHTTP As New MSXML2.XMLHTTP
Dim oStream As New ADODB.Stream
Dim oFSO As New Scripting.FileSystemObject
oXHTTP.Open "GET", sURL, False
oXHTTP.send
oStream.Type = adTypeBinary
oStream.Open
oStream.Write oXHTTP.responseBody
oStream.SaveToFile sPath, adSaveCreateOverWrite
oStream.Close
Set oXHTTP = Nothing
Set oStream = Nothing
Set oFSO = Nothing
End Sub