browseEmbed (bemb) is a project piloted by Access MVP Jack Leach of Dymeng Services that enables the communication between your VBA projects and HTML5/JavaScript via the Access 2010+ native Web Browser control.

While the techniques listed below are native to Access/VBA and allow the functionality required, in order to make good use of the VBA/JS integration, a bit of a framework needs to be put together. This framework is being actively developed using native Access/VBA and will allow developers to quickly and easily integrate bemb projects into their applications.

Use Cases

Essentially, the bemb project allows for any HTML utility to be integrated into your VBA project.  A few example use cases are as follows:

  • Rich interactive dashboards using JavaScript Charting libraries
  • Advanced navigation controls without trying to fight against the current with Access and VBA
  • HTML5/JavaScript applets for just about anything you can think of (like this Math problem widget, as one example)

The abundance of web based utilities is nearly boundless, and the being able to integrate JavaScript events into our Access/VBA applications allow us to make good use of them in more ways than I care to try and enumerate here!

Three Pillars

In order to have an embedded HTML5/JavaScript solution that’s viable as a “real” solution, there’s a few things that need to happen. First, we need to be able to manage the IE Emulation Mode of the Web Browser control so it uses a decently recent version of IE, rather than its default emulation of IE7. Secondly, we need to be sure that the web content can run unhindered when loaded directly from our computer instead of from the web – a common problem with IE, and finally we need a way to subscribe to HTML element events in our VBA projects.

IE Emulation & the Web Browser Control

The Web Browser control by default runs in IE7 emulation mode, which is typically insufficient for tasks of any substantial means. Usually, we’ll want to use IE11 Emulation mode instead. This involves the setting of some registry values, as fellow Access MVP Daniel Pineault explains in this link (furthermore, use the HKCU root instead of HKLM so users (and your code) don’t require UAC to make the change – thanks to Access MVP Tom van Stiphout for working that out).

JavaScript/ActiveX & the Local Machine

If you plan to use this to read HTML from the local machine, IE may complain a bit, depending on the content contained, or just plain restrict certain required functionality.  To manage this, use MOTW as explained here:

JavaScript Events in VBA

Here it is, the last piece of the tripod.  The following MSDN article explains how to create a class module that can be used as an event handler for an HTML element:

Web Browser Control – Handling Events in Visual Basic Applications

Do note that this link refers to VB6, not VBA, and in order to work in VBA requires a bit of a trick to set the default method of a class.  Chip Pearson explains here: Setting the Default Member of a Class

More Information

View the blog post on this topic here: link to post

A QuickStart guide is available here: quickstart

Documentation for the demo project here: documentation

Download “BrowseEmbed” – Downloaded 587 times – 178 KB