Web Scraping / File Saving With VBA? Doable?

I'm trying to save a lot of files from a web site
without having to manually rightclick - save as...

The HTML I'm looking for on the file targets looks like this:

ViewDocument.aspx?DOCID=831259&MIMETYPE=application/pdf
     or
ViewDocument.aspx?DOCID=8424&MIMETYPE=application/vnd.ms-excel

I'm attaching a snippet of code used for code scraping I found on this site.
Is this possible
Sub HTMLScrape(sADDRESS As String)


Dim oHTMLDoc As New HTMLDocument
Dim oDoc As HTMLDocument
Dim oDocElements As IHTMLElementCollection
Dim oElement As IHTMLElement

Dim pos As Long
pos = 0

Set oDoc = oHTMLDoc.createDocumentFromUrl(sADDRESS, "")
Do While oDoc.readyState <> "complete": DoEvents: Loop
Set oDocElements = oDoc.getElementsByTagName("td")

For Each oElement In oDocElements
        Debug.Print CStr(pos), oElement.innerText
        pos = pos + 1
Next

Debug.Print "done"

Set oDocElements = Nothing
Set oDoc = Nothing
Set oHTMLDoc = Nothing

End Sub

Open in new window

LVL 1
JustinWAsked:
Who is Participating?
 
thenelsonCommented:
From what you describe, most likely you will want to download the files using HTTP.  This link will show you how to download files using HTTP and another technique using FTP: http://www.mvps.org/access/modules/mdl0037.htm

Here are other techniques:

You can paste the Microsoft webbrowser control into your Access form/report and then load the web address into its control source.  The web pages will be displayed in the Access form and you can interface with the pages displayed.

You can interface with Internet Explorer using Automation.

You can upload and download files using FTP - File Transfer Protocol.

You can create a hyperlink.  Clicking on the hyperlink will open the web page in the default browser.  To create a hyperlink in a form, go to Insert, Hyperlink.

This sample database will show you how to transfer information to and from the internet using the Web Browser control, Internet Explorer Automation and FTP - www.thenelson.name/#WebAccess
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.