I have a workbook with a macro to generate an HTML file and display it in a web browser embedded in one of the sheets. After testing this macro in excel 2016, I came across the problem of activeX controls described here: How to make Microsoft Web Browser object work in Excel 2016
And here's the piece of script to load the page in the web browser:
Sub LoadHTML()
Set IE = Sheets("Report").WebBrowser1
IE.Navigate2 (myFile)
End Sub
But this script returns an error if the activeX controls don't work. I found a work around with this:
Sub LoadHTML()
On Error GoTo OpenInIE
Set IE = Sheets("Report").WebBrowser1
IE.Navigate2 (myFile)
Exit Sub
OpenInIE:
With New InternetExplorer
.Visible = True
.Navigate myFile
End With
End Sub
Is there a way to check if the activeX controls work without generating an error?
And, BTW, if the activeX controls are not fixed and the HTML file needs to be opened in an external browser, is it possible to open the file in the default system browser instead of IE?