0

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?

YowE3K
  • 23,852
  • 7
  • 26
  • 40
Herby
  • 1
  • 2
  • google this `PropertyExists Routine Using TLBINF32.DLL` ... it appears to be deprecated but your system may still have it (ms windows) .... examine the `activesheet.shapes` object in the watch window (with IE activex on the worksheet) .... there may be something that you can check ..... for the external web browser use the `shell` command – jsotola Oct 29 '17 at 07:51
  • second part https://stackoverflow.com/questions/3166265/open-an-html-page-in-default-browser-with-vba#3166322 – jsotola Oct 29 '17 at 08:23

1 Answers1

0

found a way to check for the presence of IE activex control

Sub checkIE()
    Dim aaa As Shape
    For Each aaa In Sheets("Report").Shapes

        Debug.Print aaa.OLEFormat.progID

        If aaa.OLEFormat.progID = "Shell.Explorer.2" Then MsgBox "we have IE"

    Next aaa
End Sub
jsotola
  • 2,238
  • 1
  • 10
  • 22