Retrieve Data from Website in Microsoft Access or Excel using VBA

File Download: Microsoft Access/VBA Sample File

Edit: 7/23/2017 – an improvement to this solution. This will require some refactoring.

A week or so ago a reader asked (on this blog post), if we could place the file online that performs the operation in this blog post (and video).

I’ve included it below as a download.

DOWNLOAD: Access Database Example

The download is a zip file.

  1. Download and extract. Open the “pulse-grab-web-data.accdb” file.
  2. Open the form, “frmRetrieveWebData” in design view
  3. Right mouse click the button and select, “Build Event” to see the code
  4. Set a break point if you want to see the code run line by line
  5. View the form in standard (form) view
  6. Press the “Get Web Data” button
  7. When complete, the “tblWebData” table should open.

Note: as of today (9/7/2016) this code runs. If we change our blog or theme, it is likely this will no longer work. Sorry. 😉

COMING SOON: We’ll have an update on connecting Microsoft Access to Quickbooks..

Posted in Consulting, Microsoft Access, Programming, Tips and Tools and tagged , , .

9 Comments

  1. Thank you for the demo, I have done this before but needed to demo to work the concept of Screen Scraping (as such), to find a clear and simple demo already bundled was gold.

  2. Thank you very much, matthew! actually, I have a task to retrieve certain data from several web pages (actually one main page and sub-pages). If you could help me I will be very grateful!!

    • T.Salih, I’m glad you found this helpful.

      How can I help you?

      Are the pages you are retrieving data from always at the same URL?
      Main Page
      Main Page/Subpage1
      Main Page/Subpage2

      for instance:

      As is the data in the same location or otherwise in the same DOM element or id/class?

      If so, it should be fairly simple to make this happen.

  3. When i Run the Access database example…after clicking the button, i get an error: run-time 91 Object variable or with block variable not set.

    • Hi Mark,

      Can you debug and let me see what line that is? Also, what version of office?

      The real problem is that this code was written to read the blog entries from our website but we no longer use the same theme.-This means the Document Object Model being referenced in the code does not exist any longer. I have more recent examples – but, again, they are simply examples. You need to modify based on the site you are hoping to extract data from.

  4. Never mind, i found the problem. The lines are regering to a html tag that does’t excist on your current website template. I changed it and i got it to wotk. Thanks, your example helpend a lot

  5. using your dbase I get runtime error 91

    “object variable or with block variable not set”

    is there a way to use ms Edge instead of internetExplorer?

    • Hi Brian,

      It’s been awhile since I’ve touched this project. I’ve never been able to use Edge but I read an article a year or so ago about some tweaks that allowed that. I cannot recall if I even tried it. Sorry.

Leave a Reply

Your email address will not be published. Required fields are marked *