Search code examples
vbaexcelbrowserexcel-2013

Addressing a web browser ActiveX control fails in VBA (Excel 2013)


I'm having trouble with a piece of code I wrote a while ago for Excel 2007. I'm now using Excel 2013 and it's throwing a 438 runtime error.

Here's the line that throwing the error.

 ActiveSheet.WebBrowser1.Visible = True

I've checked in design mode that the web browser object definitely exists in the active sheet and is called 'WebBrowser1'. I've also checked that MS Internet Controls is enabled. Have MS changed the way the WebBrowser object works?


Solution

  • I've found the problem and a workaround for my own machine but would really appreciate advice on a better way to handle this for distribution to other users.

    The problem is that there is a KillBit set for the web browser object due to a security issue.

    The workaround (which presumably leaves the user open to the security issue) is to go into the registry and change the value from 400 to 0. The address for my 64 bit system is: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Common\COM Compatibility\{8856F961-340A-11D0-A96B-00C04FD705A2} but if you search for "COM Compatibility" you should find the right place.

    After closing and restarting Excel the web browsers appeared and function as expected.