ms-accesshref

MS Access Edge Browser Control to call a telephone number (W10)


I'm trying to create a simple form to show a phone number that a user can click to initiate a call. The main issue is how to 'load' the html to be displayed as the Browser Control is designed to load a URL.

After a lot of hunting I have got the old Web Browser Control to do this. It shows the link and a click opens the Windows pop-up asking which App to use.

Its replacement is the Edge Browser Control which is not compatible - it needs its own code.

After lots of failed attempts, the code from HevHut here got me as far as loading the html.

Opening the form shows the phone number link but on clicking the link there is no pop-up - all that happens is that the form turns dark grey and does nothing.

The relevant code in the Form_Load even consists of:

w = "<a href='tel:5555555555'>call 5555555555</a>"
sJS = "document.open();document.write(""" & w & """);document.close();"
Me.EdgeBrowser2.Navigate "about:blank"
Do
    DoEvents
Loop Until EdgeBrowser2.ReadyState = READYSTATE_COMPLETE    'READYSTATE_COMPLETE=4
Me.EdgeBrowser2.ExecuteJavascript sJS

I have tried omitting lines 3 to 6 and it behaves exactly the same.

In contrast the old Browser Control code

Set webControl = Me.Wb.Object
With webControl
    .Navigate "about:blank"
    Do
        DoEvents
    Loop Until webControl.ReadyState = READYSTATE_COMPLETE 'READYSTATE_COMPLETE=4
    .Document.Write "<a href='tel:5555555555'>Call the store</a>"
End With

works.

Using the Edge browser control for a regular web site, or using identical code as at the top, but replacing the href string with a regular URL works just fine.

I tried a 'mailto:' link and that behaves exactly like the 'tel:'

Finally I tried 'mailx:' with the same result.

I conclude that there is no support for tel: and mailto: links.

Could there be some setting or other that has to be activated?


Solution

  • You really, really, do not need to pull-in an entire modern (and RAM-demolishing) browser engine just to have tel: (or callto:) URIs handled appropriately.

    All you need is ShellExecute - which is already easily accessible in VBA/VB6:

    1. Open Access' VBA editor:

    enter image description here

    2. Add a reference to Shell32:

    enter image description here

    2.1. Open the References window.
    2.2. Add a reference to "Microsoft Shell Controls and Automation"

    3. Write the Subroutine:

    This Sub-routine simply passes any String-typed uri parameter down along to ShellExecute.

    Sub OpenUri(uri As String)
    
        Dim shl As Shell32.Shell
        Set shl = New Shell32.Shell
        
        shl.ShellExecute uri
    
    
    End Sub
    

    It really is that simple. No Formula-1-race-car-just-to-go-to-the-shops web-browser engine required.


    The screenshot below shows me trying to make a test call with the tel: URI scheme, and it shows Windows prompt me to choose Teams or Skype (or another browser) to handle the tel: URI because I don't actually have a default tel: handler set yet)

    enter image description here

    enter image description here