I've got a Excel VBA application (with a custom menu) that works fine in Excel, but has problems when the Excel file is opened with Internet Explorer.
Is there a way for code to determine whether or not IE is the top-level application? Application.Name equals "Microsoft Excel" in both cases.
In particular the Controls.Add method fails in the code below. (The same code runs without error if triggered manually after the workbook finishes loading.) Since Excel's menu is not even displayed when running under Internet Explorer, all I really need is some logic in my Workbook_Activate sub that checks to see if Excel is being run within IE.
But how do I test for being run under IE?
'in ThisWorkbook module
Private Sub Workbook_Activate()
Call LoadCustomMenu
End Sub
Public Sub LoadCustomMenu()
Dim CustomMenu As CommandBarPopup
Set CustomMenu = Application.CommandBars(1).Controls.Add(Type:=msoControlPopup, temporary:=True)
'... etc.
End Sub
If it's relevant, I'm testing with Excel 2003, but I need 2007 to work also.
Bookmarks