VBA Web Scrapping

There’s so much information out there to do this that I hardly beleive that I will add any interesting thing. But having all integrated in a post is as usefull as knowing how to do it. Let’s get on the matter.

The information for this post came from several sites:

First of all, you will need these references (add manually if they are not already loaded in the reference panel):
  • ietag 1.0 Type Library
  • iextag 1.0 Type Library
  • Microsoft HTML Object Library
  • Microsoft Internet Controls

Then, you could try several options:
InternetExplorer instance, declared as:
Dim objIE As Object: Set objIE = CreateObject("InternetExplorer.Application") 'for late binding (no references needed)
Dim objIE As HDocVw.InternetExplorer: Set objIE = New HDocVw.InternetExplorer ' for early binding (need references)
Here we have a first divergence, if browsing local pages or net pages. For local, we should use Internet Explorer Medium instead of the normal instance. If should be declared as: 'Set objIE = New InternetExplorerMedium Set objIE = CreateObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}") 'Internet Explorer Medium Set objIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}") 'Internet Explorer Medium

Leave a Reply

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