Outlook 2007 run macro at startup

E

Ed White

I've been trying to get a macro to run when I start up Outlook 2007, but I
can't get it to work. I've tried it both with Macro with 'Warnings for all
macros' and with 'No security check for macros' checked, and it didn't run.
I've tried creating the sub with the name 'Sub Application_Startup()' and
with the name 'Sub AutoExec()', and I've put the sub in either
ThisOutlookSession and in Module1, but it just doesn't run at startup. What
am I missing?
 
C

Colbert Zhou [MSFT]

Hello Ed,

Good day!

When I choose the security option "No security check for macros", the Sub
Application_Startup() approach works fine.

The followings are my steps,
1. Press Alt+F11 to open the VBA Editor,
2. In the Project window, double click the ThisOutlookSession, so the code
editor pops up in the right panel.
3. In the right panel, select Application in the first combobox, and select
Startup in the second.
4. Then the VBA IDE will generate the following Sub for us, and I insert a
Msgbox there
Private Sub Application_Startup()
Msgbox "Test"
End Sub
5. In the security dialog, select the "No security check for marcos".
6. Close and restart Outlook, and Outlook pops up a "Test" message box.

Note that in the step 6, it will ask us to save the VBA project, and we
select the "Yes" option. Please let me know if we were performing the same
steps. And another thing to mention, before we restart Outlook, we can use
the task manager to make sure the Outlook is already closed. Sometimes, the
Outlook does not terminate immediately.


Best regards,
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
E

Ed White

I was doing pretty much exactly what you described. I believed the issue was
your "And another thing...", i.e. that when you close Outlook, it often is
still running in the background, and when it is running in the background and
you restart Outlook (e.g. from the Start menu), it doesn't run the
Application_Startup sub. If I use the Task Manager to ensure that Outlook is
closed before I restart it, then the sub appears to run every time. Thanks.
 
R

Rich Wasilewski

Place you startup code in the subrouting after MAPI login complete.

Private Sub Application_MAPILogonComplete()

Call Your macro1
Call your macro2

End Sub




EdWhit wrote:

I was doing pretty much exactly what you described.
21-Jan-09

I was doing pretty much exactly what you described. I believed the issue was
your "And another thing...", i.e. that when you close Outlook, it often is
still running in the background, and when it is running in the background and
you restart Outlook (e.g. from the Start menu), it doesn't run the
Application_Startup sub. If I use the Task Manager to ensure that Outlook is
closed before I restart it, then the sub appears to run every time. Thanks

:

Previous Posts In This Thread:

Outlook 2007 run macro at startup
I've been trying to get a macro to run when I start up Outlook 2007, but I
can't get it to work. I've tried it both with Macro with 'Warnings for all
macros' and with 'No security check for macros' checked, and it didn't run.
I've tried creating the sub with the name 'Sub Application_Startup()' and
with the name 'Sub AutoExec()', and I've put the sub in either
ThisOutlookSession and in Module1, but it just doesn't run at startup. What
am I missing
--
Ed

Hello Ed,Good day!
Hello Ed

Good day

When I choose the security option "No security check for macros", the Sub
Application_Startup() approach works fine.

The followings are my steps
1. Press Alt+F11 to open the VBA Editor
2. In the Project window, double click the ThisOutlookSession, so the code
editor pops up in the right panel
3. In the right panel, select Application in the first combobox, and select
Startup in the second
4. Then the VBA IDE will generate the following Sub for us, and I insert a
Msgbox ther
Private Sub Application_Startup(
Msgbox "Test
End Su
5. In the security dialog, select the "No security check for marcos"
6. Close and restart Outlook, and Outlook pops up a "Test" message box

Note that in the step 6, it will ask us to save the VBA project, and we
select the "Yes" option. Please let me know if we were performing the same
steps. And another thing to mention, before we restart Outlook, we can use
the task manager to make sure the Outlook is already closed. Sometimes, the
Outlook does not terminate immediately.

Best regards
Colbert Zhou (colbertz @online.microsoft.com, remove 'online.'
Microsoft Online Community Suppor

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

I was doing pretty much exactly what you described.
I was doing pretty much exactly what you described. I believed the issue was
your "And another thing...", i.e. that when you close Outlook, it often is
still running in the background, and when it is running in the background and
you restart Outlook (e.g. from the Start menu), it doesn't run the
Application_Startup sub. If I use the Task Manager to ensure that Outlook is
closed before I restart it, then the sub appears to run every time. Thanks

:

EggHeadCafe - Software Developer Portal of Choice
Easy Cross-Browser Collapsible Divs Redux
http://www.eggheadcafe.com/tutorial...63-6e9095a9597a/easy-crossbrowser-collap.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top