Solution: Application_Startup in ThisOutlookSession Outlook2007 does not fire
Private Sub Application_Startup()
MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser
Application.ActiveExplorer.WindowState = olMaximized
End Sub
But because Application_Startup will only occurs when Microsoft Outlook starts, after all add-in programs have loaded. An unknown bug from one of the patches in the latest Outlook 2007 may have left the starting process ‘hanging’. This means that macros would not fire because outlook still thinks it haven’t started. A strong suspect is the Show.SenderPhoto_OutlookAddin.Connect which you can find under Help->Disabled Items.
When you look under Tools->Macros (or press Alt-F8) when Outlook ‘started’, you will not see ThisOutlookSession.Application_Startup listed in any of the macros. If you remove the word Private in the above subroutine, ie
Sub Application_Startup()
MsgBox "Welcome, " &
Application.GetNamespace("MAPI").CurrentUser
Application.ActiveExplorer.WindowState
= olMaximized
End Sub
the macro will show up Alt-F8. However, it will still NOT fire due to the bug. I had googled for days for solutions and there are several suggestions to
- Lower the Macro Security
- Disable all the Addins/COM
- Sign the Macros using self.cert
- Add certificate to Trusted Publisher
- Change VbaProject.OTM to VbaProject.OTM.old to force outlook to start a fresh one
- and so on……
I have tried all those but all doesn’t work. Until I stumbled onto this method. This is a sort of a bandage and will at least get you going until Microsoft comes up with the fix. It is very simple, just add in a switch so that Outlook will trigger Macro when launch.
Solution: You add a switch to launch the macro you want when you start Outlook, by appending the correct code in the property of the outlook application or the shortcut. Above shows the shortcut method. Note that even if you put a bogus macros after /autorun, it stills trigger Application_Startup because now Outlook think it has started.
It seem like even if you have some realcode, for example under abc123 macro as above, when outlook launch, it will just fire Application_Startup and won’t continue to abc123, so my suggestion is to call abc123 from inside Application_Startup.
Thank you so much !!! You made my day with this post, solves the apllication_itemsend not firing too 🙂
You are welcome. I can understand the frustration as I was in the same situation, even till now there is so much weird quirks with outlook.
SUper! works great!
That was a welcome and simple fix to an annoying problem.
I found that setting Outolook to start minimized caused the problem. Open the shortcut setting and set “Normal window” on the “Run” field does the trick.