VBA & Macro Problems

Update Excel VBA Web Scraping from Internet Explorer to Selenium

Emma BrownEmma Brown Nov 12, 2026 868 views

Question details

The user needs to modernize an Excel VBA web-scraping macro that previously automated Internet Explorer and read webpage HTML through the DOM.

Update Excel VBA Web Scraping from Internet Explorer to Selenium
Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
An existing macro retrieves information from websites using InternetExplorerMedium and HTMLDocument objects, but Internet Explorer is no longer supported.
Observed behavior
The Internet Explorer-based automation approach cannot be transferred directly to a modern browser and must be replaced with browser automation or direct web requests.
Before you start

Identify whether the target website provides an API or allows the required data to be requested directly before setting up browser automation. If browser automation is necessary, verify that the selected WebDriver version is compatible with the installed Chromium-based browser.

Solution 1Recommended

Replace Internet Explorer Automation with Selenium WebDriver

Use this approach when the website requires a real browser to render JavaScript, sign in, click controls, or load dynamic content.

Selenium controls a modern browser such as Google Chrome or Microsoft Edge through a WebDriver. The existing InternetExplorerMedium and HTMLDocument objects cannot simply be changed to point to Chrome or Edge; the navigation and element-selection code must be rewritten for Selenium.

Use stable element locators such as id, name, CSS selector, or XPath, and wait for the target element to load before reading its text or attributes.

1
Install a Selenium-compatible VBA setup

Install a VBA-compatible Selenium/WebDriver library and download the ChromeDriver or Edge WebDriver version that matches the browser installed on the computer. Add the required Selenium reference in the VBA editor through Tools > References.

2
Open the VBA editor and create a replacement procedure

In Excel, press Alt+F11, then select Insert > Module. Create a new procedure that initializes a Selenium WebDriver instance for Chrome or Edge instead of creating an InternetExplorerMedium object.

3
Navigate and locate page elements

Use the WebDriver navigation method to open the required URL, then locate content with a CSS selector, id, name, or XPath. Add an explicit wait before retrieving data from elements that are loaded by JavaScript.

4
Read the data and close the browser session

Write the retrieved text or attribute values to worksheet cells, then call the WebDriver Quit method at the end of the procedure to close the automated browser session.

Replace Internet Explorer Automation with Selenium WebDriver
Modern browser automation requires new code: Selenium exposes browser elements through WebDriver methods, so Internet Explorer DOM variables and InternetExplorerMedium-specific commands must be replaced rather than reused unchanged.
Free Microsoft Office alternative

Use WPS Office for Everyday Spreadsheet Work While Updating Legacy VBA

Internet Explorer retirement affects legacy Microsoft Excel browser-automation code and requires a Selenium or web-request redesign. While that migration is handled in the appropriate VBA environment, WPS Office provides a free, lightweight spreadsheet alternative with a familiar interface and convenient migration for standard workbook tasks.

Open and edit Excel XLS and XLSX workbook formats with strong compatibility.Use a familiar spreadsheet interface for formulas, tables, charts, and routine data work.Work with a free and lightweight Office suite during a Microsoft Office transition.Continue reviewing and organizing web-scraped data in compatible spreadsheet files.
microsoft office alternative - wps office

Frequently Asked Questions

Can I replace InternetExplorerMedium with a Chrome object in VBA?

No. Chrome and Edge do not expose the old Internet Explorer COM automation model. Replace the InternetExplorerMedium workflow with Selenium WebDriver commands or use a direct HTTP request when an endpoint is available.

When should I use XMLHTTP instead of Selenium for VBA web scraping?

Use XMLHTTP when the site provides an API, JSON endpoint, XML feed, CSV export, or another response that contains the required data without page interaction. Use Selenium when the data is rendered by JavaScript or requires actions such as sign-in, clicking, or scrolling.

Where do I add Selenium references in Excel VBA?

Open the Visual Basic Editor with Alt+F11, then select Tools > References. Select the installed Selenium-compatible library after its installation, and create or update code in a standard module through Insert > Module.

Why does an old HTMLDocument scraping macro stop working after Internet Explorer retirement?

The macro depends on Internet Explorer's browser engine and COM objects, including InternetExplorerMedium and HTMLDocument. Modern Chromium-based browsers use a different automation model and require WebDriver-based element access.