Original post:
When Outlook is launched, the Add-In is loaded and adds a toolbar with some buttons.
toolBar = OutlookApp.ActiveExplorer().CommandBars.Add(MENU_TAG, MsoBarPosition.msoBarTop, false, true);
Everything was working fine, but now one user has his Outlook shortcut set to launch Outlook minimized.
And then OutlookApp.ActiveExplorer() return null. Is there some event I can use to catch when there is an ActiveExplorer and then add the commandbar?
OutlookApp.Explorers.NewExplorer doesn't work.
Also, when I show a messagebox before I add the CommandBar: everything works fine, even with Outlook minimized... Why?
edit:
Accessing the Explorers proprerty directly did work, as someone said in the answers. So this solves the problem for a minimized outlook... But...
One of the users does not have Outlook run minimized, and still the plugin loads before any gui is available. There are not even 1 explorer in the Explorers collection :( How is this possible?
edit 2:
I tried using a timer as suggested by 76mel, checking ActiveExplorer for null every 100ms. This adds the buttons as expected, but I can set the Picture property of the button.
I get this exception:
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))