Automating Edge Browser using VBA without downloading Selenium

There are now many ways to achieve this.

Method 1

As of 25th April 2022, you can now directly automate Edge IE Mode with VBA without any additional third party-software. The below guidance has been well tested by me and my colleagues after obtaining it from exchanging with our partnered Microsoft Support team.

Win Upgrade + Registry Fix

  1. Your Windows version needs to be at least 20H2. You can check your Windows version with this guide here.

  2. Your Windows needs to have the latest cumulative KB update past March 2022. You can check your Windows update history with this guide here.

  3. Finally install the below registry keys on your Windows and restart:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main]
    “NotifyDisableIEOptions”=dword:00000002

    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Main\EnterpriseMode]
    “EnableGlobalWindowListInIEMode”=dword:00000001

Per the MS Support team, the above method should work until 2029. Official documentation on this might be coming soon I believe.

After the above steps, VBA shall be able to interact with Edge IE Mode as if it is an Internet Explorer window. Your current code that automates the InternetExplorer.Application object will work with Edge IE mode as well.

Method 2

You can also employ the following method written by ChrisK23 of CodeProject that makes use of Chrome Devtools Protocol to interact with Chromium-based browsers. The advantage of this method is that it allows VBA to interact directly with Edge without IE mode and also with Chrome.

Automate Chrome / Edge using VBA via CDP – Code Project

The article above also includes an example file which you can download and explore the method. However, do note that the example file is missing Microsoft Scripting Runtime reference which you need to include this manually afterwards to make it working.

With this method, you can now automate even Chrome without additional software installed.

I have created a dedicated Git with a demo file to this method here:

https://github.com/longvh211/Chromium-Automation-with-CDP-for-VBA

Method 3

Another method involves using winAPI to retrieve the HTML document object from Internet Explorer Server class of the running Edge IE Mode window.

Sample Code 1
Sample Code 2

Note: the above codes are for Office 32-bit. For Office 64-bit you will need to convert them (refer to this MSDN link for more details)

The pros of this method is that it is quite clean and interact well with Edge IE Mode without any additional setup or installation.

The cons is that it only works with Edge IE mode. Hence web applications that run only on Edge and not IE mode will not be automatable using this method.

You can refer to this dedicated Git in which I have prepared a demo file here:

https://github.com/longvh211/Edge-IE-Mode-Automation-with-IES-for-VBA

Leave a Comment