invoke vba when button is clicked on edge browser control

whylikethis

New member
Local time
Today, 06:39
Joined
Sep 14, 2024
Messages
1
hey guys,
I have a local html page with js.. when a user press a button on my html page i want to execute a vba code.
how can i know when the button was clicked on my new Edge control?

limitations:
* can't install additional software like selenium..
* cant use timer on the form because it makes errors for my users.

thank you!! :)
 
In the regular browser control, the procedure is this:
1. Add a reference to Microsoft HTML Object Library
2. Take control of the document object in the browser control
3. Declare a WithEvents variable of type HTMLButtonElement (if the element to click is actually a button tag)
4. Initialize the variable somewhere, maybe On Load
5. Select the click event for your WithEvents variable from the VBA IDE dropdown selector
6. Add the code to that procedure

As for the Edge browser control, I don't know, but it will likely involve dealing with JavaScript instead. So:
1. Open Developer tools to inspect the document
2. Find the element you want to click
3. Add the JavaScript function that will run with click
4. Add a click event listener to the button to be clicked

Since I do not have the Edge browser control installed, I cannot confirm how to trigger a usable event for MS Access. However, the Edge browser control likely has a method for this purpose. As a workaround if there was no such method, I would also add a JavaScript function to make the control trigger one of its built-in events.
 
D Pineault has an excellent example of this:-

 

Users who are viewing this thread

Back
Top Bottom