Skip to content

Solution: Application_Startup in ThisOutlookSession Outlook2007 does not fire

June 12, 2010

Application_Startup seem to have broke and cannot fire when you launch Outlook 2007. Normally, you would put some code inside Application_Startup inside ThisOutlookSession, an example given by Microsoft Help would be

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

  1. Lower the Macro Security
  2. Disable all the Addins/COM
  3. Sign the Macros using self.cert
  4. Add certificate to Trusted Publisher
  5. Change VbaProject.OTM to VbaProject.OTM.old to force outlook to start a fresh one
  6. 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.

Advertisements
7 Comments
  1. Eelco Akker permalink

    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.

  2. SUper! works great!

  3. Puddy permalink

    That was a welcome and simple fix to an annoying problem.

  4. 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.

Trackbacks & Pingbacks

  1. How to open PDF attachement upon arrivel new mail - Page 2
  2. Outlook Application_Startup() Failure and Workaround ~ ian-scott.net

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: