Fix VBA EdgeDriver Object Variable Not Set in SeleniumBasic
Question details
The user is encountering an 'Object variable or With block variable not set' error when attempting to create an EdgeDriver object in Microsoft Access VBA using SeleniumBasic.
- Product
- VBA / SeleniumBasic
- Device & OS
- Windows 10
- Scenario
- Running a VBA script to automate the Microsoft Edge browser with SeleniumBasic after the operating system was reimaged.
- Observed behavior
- The VBA program fails to instantiate the EdgeDriver object during the 'Dim EDGE As New EdgeDriver' command, resulting in a runtime error.
Ensure you have an active internet connection to download the required driver files and know your exact current version of the Microsoft Edge browser.
Update Microsoft EdgeDriver to Match Browser Version
The most common cause for the EdgeDriver failing to initialize in SeleniumBasic is a version mismatch between the installed Edge browser and the EdgeDriver executable.
When Windows is reimaged or Microsoft Edge automatically updates, the browser version changes. If the EdgeDriver in your SeleniumBasic folder is older or corresponds to a different build, the VBA integration will fail to create the session, throwing the 'Object variable not set' error.
Open Microsoft Edge. Click the three horizontal dots (Settings and more) in the top right corner. Navigate to 'Help and feedback' > 'About Microsoft Edge' and note the exact version number displayed.
Go to the official Microsoft Edge Developer website (Microsoft Edge WebDriver page). Download the version of the WebDriver that perfectly matches the browser version you noted in the previous step.
Extract the downloaded ZIP file. Locate the 'msedgedriver.exe' file inside and copy it. Paste and replace the existing file in your SeleniumBasic installation folder (typically located at C:\Users\[Username]\AppData\Local\SeleniumBasic).
Close Microsoft Access (or your VBA host application) and reopen it. Run your VBA automation script again to verify that the EdgeDriver object instantiates successfully.
Looking for a Seamless Office Alternative with Macro Support?
If you frequently work with VBA macros and automation but want a more cost-effective solution, consider trying WPS Office. It provides a robust, built-in VBA environment in WPS Spreadsheets and high compatibility with Microsoft Office file formats.
- 1. Download and Install WPS Office: Visit the official WPS website, download the free installer, and complete the quick installation process.
- 2. Open Your Macro-Enabled Files: Launch WPS Spreadsheets and open your existing .xlsm or .xlsb files directly without format conversion.
- 3. Enable and Run VBA: Navigate to the 'Developer' tab in WPS Spreadsheets to access the VBA Editor and execute your automation scripts.

Frequently Asked Questions
Why does SeleniumBasic throw an 'Object variable not set' error?
This error typically occurs when the automation driver (like EdgeDriver) fails to instantiate the browser session. In most cases, this is caused by a version mismatch between your web browser and the WebDriver executable in the SeleniumBasic folder.
Where is the default SeleniumBasic installation folder located?
By default, SeleniumBasic installs to the user's local AppData folder. You can usually find it at 'C:\Users\[YourUsername]\AppData\Local\SeleniumBasic'. This is where you need to place your updated WebDriver executable files.
Can I automate web browsers using VBA in WPS Office?
Yes, WPS Spreadsheets supports Visual Basic for Applications (VBA). You can install SeleniumBasic, reference it in the WPS VBA editor just as you would in Microsoft Office, and run your web automation scripts.
How do I ensure my EdgeDriver doesn't become outdated again?
Because Microsoft Edge updates automatically in the background, your driver will eventually mismatch again. You can either turn off automatic Edge updates (not recommended for security reasons) or implement a WebDriver manager script in your VBA code that dynamically downloads the matching driver version before execution.




