dlh
03-22-2010, 10:51 AM
How can I tell if my Excel VBA code is running in shell-mode within Internet Explorer?
I have a custom menu that's created in the Workbook_Activate procedure, but when an Excel file is opened inside a browser window, the Activate event seems to be triggered before the menu objects are available. At least that's my guess of what's happening. The symptom is the Controls.Add method fails.
So I'm trying to figure out some logic to avoid calling my LoadCustomMenu subroutine if the user is not running stand-alone Excel. I don't really need the menu in this situation, but I need the VBA code to not abort.
I tried testing the values of Application.Name and Application.Parent.Name, but they equal "Microsoft Excel" all the time. Any expert advice would be very much appreciated. My existing code is below.
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
I have a custom menu that's created in the Workbook_Activate procedure, but when an Excel file is opened inside a browser window, the Activate event seems to be triggered before the menu objects are available. At least that's my guess of what's happening. The symptom is the Controls.Add method fails.
So I'm trying to figure out some logic to avoid calling my LoadCustomMenu subroutine if the user is not running stand-alone Excel. I don't really need the menu in this situation, but I need the VBA code to not abort.
I tried testing the values of Application.Name and Application.Parent.Name, but they equal "Microsoft Excel" all the time. Any expert advice would be very much appreciated. My existing code is below.
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