VBA & Macro Problems

How to Automate Internet Explorer Confirmation Dialogs with VBA

Muhammad TalhaMuhammad Talha Nov 11, 2026 869 views

Question details

The user needs a way to programmatically interact with a 'Yes/No' confirmation dialog that appears after clicking a button on a webpage via VBA.

How to Automate an Internet Explorer Confirmation Dialog Using VBA
Product
VBA / Internet Explorer
Device & OS
not provided
Scenario
Running a VBA web scraping or automation script where a secondary pop-up blocks the execution flow.
Observed behavior
The VBA procedure cannot click the confirmation dialog using standard DOM methods, and the script hangs waiting for user input. Power Automate also fails to interact with the dialog.
Before you start

Ensure your VBA editor is open and that your computer will remain untouched during script execution, as this workaround relies on the browser maintaining active window focus.

Solution 1Recommended

Use Application.SendKeys to Handle the Dialog

This workaround sends keyboard strokes directly to the active window to dismiss the dialog, bypassing the inability to target it via HTML elements.

Because confirmation dialogs are OS-level or browser-level modal windows, standard HTML Document Object Model (DOM) methods cannot interact with them. By ensuring the browser is the active window, you can simulate a keyboard 'Enter' press to accept the dialog.

1
Make the Browser Visible

In your VBA code, ensure the Internet Explorer object is visible and active by adding `ie.Visible = True` before triggering the button.

2
Trigger the Webpage Button

Click the webpage button using its actual HTML ID in the DOM, for example: `ie.document.getElementById("SubmitButton").Click`.

3
Pause the Script Briefly

Add a short delay to allow the confirmation pop-up to fully render on the screen. Use `Application.Wait (Now + TimeValue("0:00:02"))`.

4
Send the Enter Keystroke

Execute `Application.SendKeys "{ENTER}"` to simulate pressing the Enter key, which typically triggers the default 'Yes' or 'OK' option on the confirmation pop-up.

Use Application.SendKeys to Handle the Dialog
SendKeys Reliability: Application.SendKeys can be unreliable. If another application steals window focus while the script is running, the Enter keystroke will be sent to the wrong application. Avoid interacting with the computer while the macro runs.
Free Microsoft Office alternative

Upgrade Your Spreadsheet Tasks with WPS Office

While Internet Explorer automation is now obsolete, modernizing your workflow is easier than ever with WPS Office. As a lightweight, feature-rich suite, it offers excellent support for advanced data processing, macros, and seamless compatibility with your existing files—all for free.

Fully compatible with Microsoft Excel formats (.xlsx, .xls, .xlsm).Built-in robust macro and VBA support for automating spreadsheet tasks safely.Lightweight installation with incredibly fast loading times.Familiar, user-friendly interface that makes switching seamless.
microsoft office alternative - wps office

Frequently Asked Questions

Why can't standard VBA click the Yes/No confirmation dialog?

Standard VBA web automation interacts with the HTML Document Object Model (DOM). Confirmation dialogs are typically generated by the browser or operating system as modal pop-ups, existing outside the webpage's HTML structure, making them invisible to standard DOM targeting methods.

Is Application.SendKeys safe to use for automation?

While useful as a quick workaround, Application.SendKeys is generally considered unreliable. If a user clicks away or another background application steals focus while the script is running, the keystrokes will be sent to the wrong window, which could cause unintended actions on your PC.

Are there better alternatives to automating Internet Explorer?

Yes. Internet Explorer is obsolete and no longer supported by Microsoft. It is highly recommended to migrate your automation to modern tools. Excellent alternatives include Selenium Basic for VBA, Python (with Selenium or Playwright), or modernizing your flows using Microsoft Power Automate Desktop with supported browsers like Edge or Chrome.