Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

Lets say the ActiveSheet is Sheet1 Goto Object Browser > check for Class sheet1 under classes > Look for Members of Sheet1 ("WebBrowser1" should be there as a property)

Now Search for Class WebBrowser under Classes > Look for Members of WebBrowser (Check if Visible property is there. If yes (Sheet1.WebBrowser1.Visible = True) should work for you.

Else navigate through the property and identify which other property can be used to hide (you may guess it by name))

'this works in Excel 2013
Dim wb As WebBrowser: Set wb = Sheets("sheet1").Shapes("WebBrowser1").DrawingObject.Object
wb.Navigate url

I am guessing, as I cannot find any documentation to substantiate this, that in Excel2007 the default attribute of the Worksheet object must have been Shapes or a collection of objects on the sheet. I too have noticed the ws.WebBrowser1 way of referencing the WebBrowser object instance on a sheet on the web, but in Excel2013 it does not work. And Shapes is not Worksheets default attribute. I'll keep looking...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top