WebBrowser ActiveX Control – Google Maps Invalid Character Scripting Error

I had an MS Access database which had been in place for over a year and that was working just fine.  One day, at the beginning of October 2013, my client informed me that they had recently started receiving a Scripting error (see the image below) every time the form displayed a map (Google Maps) of an address, any address.

WebBrowser_GoogleMaps_Script_ErrorAt first, I assumed it was a Google glitch and figured we’d give the Google team a chance to rectify whatever the issue was.  That said, days, weeks, went by and the problem remained.  So it was time to do some more digging.

During the testing phase. I was able to confirm that using the same URL directly in a web browser (IE, FireFox, Chrome) all displayed just fine without any errors.  Furthermore, the error itself did not occur on every machine.  This leads me to seriously believe it has to do with some windows update that is applied to certain computers and not others.  If it were truly a Google issue, it would be generalized, which it evidentially is not!

I also, after some reading, was lead to believe it was due to Internet Explorer’s ‘Compatibility Mode’, but after performing a few simple tests, this was quickly ruled out as the source of the problem.

At this point I was at a loss as to what to do, so since I am an MS Access MVP, I sent an e-mail out to my fellow Access MVPs to see what others might suggest.  Alex Dybenko, provided me with the key piece of information to figure out the root cause of the problem.  Using a nifty piece of software that he had, he was able to identify that the WebBrowser control (with my MS Access database) was returning that it was running as a User-Agent MSIE 7.0 on his system, even though his actual IE browser was MSIE10.0?!  After performing the same test, I identified that my WebBrowser controls was reporting to be MSIE6.0 rather than MSIE10.0.

Hence, the WebBrowser control is actually running in a dumbed down mode, when compared to the actual version of Internet Explorer that you installed.  So apparently, Google Maps does not play nice with older versions of Internet Explorer.

Knowing what the actual issue what, I when digging online to see what could be done.  I eventually came across an obscure registry key that can be used to tell a program to use a specific IE emulation version.

The solution is a simple Reg Hack to for the WebBrowser control to switch it’s emulation to a more recent version of MSIE (MicroSoft Internet Explorer).

Open RegEdit and navigate to the following Registry Key (and yes you need to perform this registry hack on every computer running your database!) depending on the application using the WebBrowser control (not your OS!).

32-bit
HKLM\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION

32bit-FEATURE_BROWSER_EMULATION

64-bit
HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

64bit-FEATURE_BROWSER_EMULATION

Then create a new DWord entry in which you specify the program executable that has the WebBrowser control in it  as the ‘value name’ and use one of the following values for the Decimal ‘value data’

7000: IE7 Emulation
8000: IE8 Emulation
8888: Force IE8 Emulation
9000: IE9 Emulation
9999: Force IE9 Emulation
10000: IE10 Emulation
10001: Force IE10 Emulation
11000: IE11 Emulation
11001: Force IE11 Emulation

So since we are talking about an issue with the WebBrowser within our MS Access database, we create a DWord with msaccess.exe for the Value Name and I used 9999 as the value data. Error message gone.

As usual, you could easily create a bat, vbscript, VBA routine to push this into the registry as part of your program or installation routine!  I was recently asked if I could supply an example of such code.  As such, feel free to download  one of my samples:

WebBrowserEmulationRegistryHack_MSAccess
WebBrowserEmulationRegistryHack_MSExcel

That said, be forewarned that improper editing of the Registry can permanently damage your computer to the point of it not working anymore.  I assume no responsibility whatsoever for the sample/code provided.  It is provided for educational purposes only, and it is your responsibility to validate and test it to ensure it works properly.  It was put together rapidly in the hopes it might help, but has not been fully tested.

Also note, since it impacts the executable, in our case msaccess.exe, this hack will impact all databases containing WebBrowser controls. This could theoretically cause problems with older databases, so you could easily push the registry hack at the startup of your db and delete it upon closing, to try and minimize impacting other databases. Obviously, if they are opened at the same time, there is little you can do.

This hack works for MS Access databases, MS Excel, WPF, Visual Studio projects, anything that uses the WebBrowser ActiveX control.

Hopefully this will help someone else!

References

If you are looking for further information, fellow MVP Tom van Stiphout recently brought the following article to my attention: Web Browser Control – Specifying the IE Version
MSDN – Internet Feature Controls (see the section entitled Browser Emulation)

 

Extra

If you aren’t looking to fix the issue, but rather simply make the error not display, you can always place the following in the Form’s load event

Me.WebBrowserControlName.Object.Silent = True

43 responses on “WebBrowser ActiveX Control – Google Maps Invalid Character Scripting Error

  1. MICHEL DEMERS

    Great work!!! Now I am somewhat a newbie, and I did build a webbrowser control to search for maps on Google map. You say it can be pushed with a VBA sub. Would you be so kind as to post in example or to send me a workbook with the sub in it?

    thank you for contributing to this solution!

    Regards,

    Michel

    1. admin Post author

      I have since created and added a downloadable sample database that you can inspire yourself with to create your own routine(s).

  2. MICHEL DEMERS

    Thank you for your quick reply,

    Since I do not have MS Access and I use MS Excel, could you post the scrip or post the VBA module instead?

    1. admin Post author

      I have uploaded a sample Excel workbook that I put together based on the technique used in MS Access. It load the reghack when the workbook is opened and then removes it when the workbook is closed. This to avoid potentially impacting other workbooks (although I truly don’t see the problem it could incur).

  3. MICHEL DEMERS

    Just tried the Excel workbook. I get an error message as vba tries to write in the registry. The error description is invalid root in registry key. (I use win 7-64bit with Office 2010-32bit).

    Info returned:
    IEMajorVersion = 9
    RegKeyExists = False via the error_handler

    This coding is above my skill level… 🙁

    Regards,

    1. admin Post author

      Not quite sure what to tell you. I tested the file on 3 different computers (WinXP and Win7, Office 2007 and 2010) and in all cases it worked. Any chance you can identify the specific line causing the problem if you run the code line by line?

        1. admin Post author

          I’m wondering if it is a permissions issue. Perhaps you need to run the script as an administrator. Do you have UAC enabled?

  4. Nick

    This worked great. We have a VB 6 application that uses the web browser control to display a google map of a customer address. All of a sudden, we started getting this error. Adding the line in the registry for our EXE fixed the issue. We force IE 8 emulation now.

  5. MICHEL DEMERS

    UPDATE: As suggested by Admin, even if you are the administrator user, you need to turn off totally the UACS (control panel / User Accounts / Change User Account Control Settings) glide the bar down. you will be ask to restart your computer in order for the changes to take place. You can then run the code and reset UACS to your desired settings.

    Thanks Admin for the tip and all your help.

    Michel

  6. Greg

    Thank You for the article, I was running into the script error problem with a Microsoft Visual FoxPro web app. I just downloaded IE 11 Beta and it also stopped the script error. Thank You again.

  7. ravikas

    Thanks! I have c# app which uses webbrowser control and got same error, solution works perfectly!

  8. Eduardo

    Muchas gracias desde Granada.
    Tenemos una aplicacion en VFP y nos pasaba lo mismo. En nuestro caso, habíamos encontrado este mismo fix en una web de VFP pero en vez de vfp9.exe como nos decían, gracias a este artículo he descubierto que lo que hay que poner es nuestra aplicación, en nuestro caso cqnetcon.exe

    Now in English: (sorry for my English)
    Thank you very much from Granada.
    We have a VFP application and have the same problem. In our case, we found this fix in a vfp site, but the vfp site add to the registry vfp9.exe, and this article show me that we have to add our app, in our case cqnetcon.exe

  9. Juan de Dios Espindola

    since Mexico, It works awesome !!!!!!!!!.
    and with this solve any problem of emulation of the IE, while Google Maps don´t change to a new version
    thanks…

  10. Sandi

    I have IE 11. Can you walk me through either the setting or the hack? Very, very, not familiar with RegEdits but I can get through VBA.

  11. John Turczak

    Thank you for this. I do a lot of access database work but this is my first one using a web browser and google maps. I was getting desperate on how to get rid of this error and was contemplating having to use hyperlinks instead of the control. So this is great

  12. Jorge

    I’m using Access 2013 and Internet Explorer 11. I tried the solution, but it is not working.
    Any suggestions? thanks!

    1. Daniel Pineault Post author

      So you made entry for msaccess.exe with a REG-DWORD of 0x00002af9 (11001)? You have also validated that you actually have IE11 installed?

  13. Maria

    Muchas gracias por esta exlicacion y por el programa facilitado para lograrlo. He tenido problemas al ejecutarlo, pero he optado por hacerlo manualmente y ha funcionado.

    Muchas gracias de nuevo desde España!!!!

  14. Richard Arnold

    Hello Daniel. I just recently came across this article. Your article and the Microsoft article, i.e. MSDN – Internet Feature Controls, regarding browser emulation, both stop at Internet Explorer 11 with the Decimal value of 11001 for forcing the browser control’s emulation, i.e. 11001: Force IE11 Emulation.
    I am looking to “Future-Proof” an application I’m writing and wondered if there was a way to know which decimal value to use for IE versions after version 11, in order to force the browser emulation feature in the registry? It would appear that, starting with version 10, the registry value would be 10001, version 11 is 11001. Is it same to assume that version 12 when it appears would use the value of 12001 and so on? Would there be a reliable way to know which decimal value to use for future IE versions. Thanks.

    1. Daniel Pineault Post author

      Very interesting question, but sadly I do not have a definitive answer for you. Can anyone guarantee that Microsoft will continue to follow suit with this pattern? Your guess is as good as mine.

      There is also the fact that Microsoft is launching (replacing IE with?) their new Spartan browser with Windows 10. So how will this play into the overall picture?!

      I wish I had a crystal ball, but like you, I am at the mercy of Microsoft’s limited wisdom. 🙁

      1. Richard Arnold

        Thanks for your reply. I wasn’t aware of Microsoft’s plan on changing their actual browser, i.e. Spartan. I guess I’ll have to research that browser to see how it plays into the browser emulation, as well as whether Spartan will play nice with the existing WebBrowserControl from Microsoft.
        I wonder if Spartan is merely a reworked IE, or a complete replacement. We’ll have to wait and see. But I hope MS took backwards compatibility into account. 🙁

        Thanks again.

        1. Daniel Pineault Post author

          I just there was a value which would simply imply use whatever the latest emulation mode is installed on the machine. At least have that option.

          As for Spartan, it is supposed to be a completely new browser from the ground up. They may still have IE installed because of the WebBrowser Control. For some reason I don’t think they can just dump it. It may not be front and center, but I’m assuming it will still be there in some shape or form.

  15. Marcelo

    Obrigado.
    Muito bom. Resolveu um grande problema em meu banco de dados.
    E de muitos outros para os quais vamos repassando esta solução.

  16. karique vera

    I think i love you bro, you save me from a HUUUUUUUUUUGE problem. is there a way for us to make you a donation or something?

  17. Branislav Mihaljev

    If not a late post, here is a simple solution and I actually found it in one of your files! Original post is 8 years old, but the issue exists in 2016, 365… 64-bit versions.
    Go to the Charting Access file, load it in Access 64-bit and enable browser emulation (there is a form for that in that database).
    With this file I am getting registry error while with form Browser Emulation it works.

  18. Fox

    Hi, I need your help. When I want to use a web browser element, I always get a yellow warning bar that I want to access Active-X elements. I first thought that this is due to my local configuration. Now when I open your demo database, I don’t get the warning message. How did you do/set this up? I have already compared all settings and code lines.