A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro to run on Open



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 25th 09, 07:43 PM posted to microsoft.public.outlook.program_vba
Jim
external usenet poster
 
Posts: 230
Default 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
Ads
  #2  
Old September 26th 09, 07:34 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default 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

  #3  
Old September 28th 09, 01:35 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default 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



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to open stationery Clang Outlook and VBA 7 October 5th 07 07:29 PM
Need a macro to open a form Kathy Outlook - Using Forms 2 January 24th 07 04:24 PM
VBA Macro to Open Form LDMueller Outlook and VBA 2 December 19th 06 06:54 PM
Open Form from Macro [email protected] Outlook - Using Forms 5 June 16th 06 11:42 PM
Cannot open Macro Editor antonio Outlook and VBA 2 May 10th 06 07:48 PM


All times are GMT +1. The time now is 12:59 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-2025 Outlook Banter.
The comments are property of their posters.