Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Macro to run on Open (http://www.outlookbanter.com/outlook-vba/95317-macro-run-open.html)

Jim September 25th 09 07:43 PM

Macro to run on Open
 
I have a macro that will add an attachment to the current Outlook message,
but I can't figure out how to get the macro to run automatically when the
message is opened. The message is a template (.oft). I'm new to Outlook
macros, can anyone help?

Thanks,
Jim

Michael Bauer [MVP - Outlook] September 26th 09 07:34 AM

Macro to run on Open
 


Jim, see the NewInspector event.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Fri, 25 Sep 2009 11:43:01 -0700 schrieb Jim:

I have a macro that will add an attachment to the current Outlook message,
but I can't figure out how to get the macro to run automatically when the
message is opened. The message is a template (.oft). I'm new to Outlook
macros, can anyone help?

Thanks,
Jim


Sue Mosher [MVP][_3_] September 28th 09 01:35 PM

Macro to run on Open
 
That requires an event handler, not a macro. Since you're new to VBA, I
would suggest that you stick to the macro approach and write one that starts
by loading the .oft file:

Sub MyMacro
Dim newItem as Outlook.MailItem
Set newItem = Application.CreateItem("C:\my template.oft")
newItem.Attachments.Add "C:\myfile.doc"
newItem.Display
End Sub

That will probably save you the step of locating the .oft file.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Jim" wrote in message
...
I have a macro that will add an attachment to the current Outlook message,
but I can't figure out how to get the macro to run automatically when the
message is opened. The message is a template (.oft). I'm new to Outlook
macros, can anyone help?

Thanks,
Jim





All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com