Run macro when a template is opened

1.2k views Asked by At

I have a macro in an outlook template (oft). It changes certain text in the subject and the body of the mail. I would like to know if it is possible to make this macro execute automatically when I open the template.

Thank you in advance, Santi

1

There are 1 answers

0
niton On

I suggest your template does not contain any code.

http://msdn.microsoft.com/en-us/library/office/ff865637%28v=office.15%29.aspx

Sub CreateFromTemplate() 
 Dim MyItem As Outlook.MailItem 
 Set MyItem = Application.CreateItemFromTemplate("C:\statusrep.oft") 

 ' put the code you think is in the template here

 MyItem.Display
End Sub