Vba Microsoft Internet Controls Missing
Also have the same problem but these solutions did not help.I downloaded the first patch, but I get a message that the patch is already on my machine.The 'fix it for me' is an endless list of non clear issues. Couldn't find these problem there.Anyway, within the VBA reference dialog, I see the missing file isMSCOMCT2.ocx.I searched and the file is simply not on the machine.Tx Orenmscomct2.ocx is ancient, and was removed at the OfficeXP (2002) timeframe:Can you change your solution so that it will use modern controls instead of these ancient controls?Don doesn't work for MSFT, and they're probably glad about that;.
Download DirectX End-User Runtime Web Installer. DirectX End-User Runtime Web Installer. An identified security issue in Microsoft® Visual Basic® for Applications could allow an attacker to compromise a Microsoft Windows®-based system and then take a variety of actions. By installing this update, you can help protect your computer.
Example
Tools> References> Microsoft Internet Controls
Associated DLL: ieframe.dll
Source: Internet Explorer Browser
Controls an instance of Windows Internet Explorer through automation.
Internet Explorer Objec Basic Members
The code below should introduce how the IE object works and how to manipulate it through VBA. I recommend stepping through it, otherwise it might error out during multiple navigations.
Web Scraping
The most common thing to do with IE is to scrape some information of a website, or to fill a website form and submit information. We will look at how to do it.
Let us consider example.com source code:
We can use code like below to get and set informations:
What is going on? The key player here is the .Document, that is the HTML source code. We can apply some queries to get the Collections or Object we want.
For example the IE.Document.GetElementsByTagName('title')(0).innerHtml
. GetElementsByTagName
returns a Collection of HTML Elements, that have the 'title' tag. There is only one such tag in the source code. The Collection is 0-based. So to get the first element we add (0)
. Now, in our case, we want only the innerHtml
(a String), not the Element Object itself. So we specify the property we want.
Click
To follow a link on a site, we can use multiple methods:
Microsoft HTML Object Library or IE Best friend
To get the most out of the HTML that gets loaded into the IE, you can (or should) use another Library, i.e. Microsoft HTML Object Library. More about this in another example.
IE Main issues
The main issue with IE is verifying that the page is done loading and is ready to be interacted with. The Do While.. Loop
helps, but is not reliable.
Also, using IE just to scrape HTML content is OVERKILL. Why? Because the Browser is meant for browsing, i.e. displaying the web page with all the CSS, JavaScripts, Pictures, Popups, etc. If you only need the raw data, consider different approach. E.g. using XML HTTPRequest. More about this in another example.