PDA

View Full Version : Open a simple email template out of excel



grohm
06-15-2007, 05:03 AM
Hi there. This is probably very simple, but not for me it seems

i just want to open up a email template (outlook) out of excel. the template is saved on "C:\template.oft" . I just dont know the exact wording how to declare outlook and the mailitem exactly etc. so it would really help if somebody knows this.

Thx for having a look,

Ben

mvidas
06-15-2007, 06:24 AM
Hi Ben,

A cut down version of your last question (http://www.vbaexpress.com/forum/showthread.php?t=12993#5)'s code:Sub OpenAndModifyTemplate()
Dim vOL As Object, vItem As Object

Set vOL = CreateObject("Outlook.Application")
Set vItem = vOL.CreateItemFromTemplate("C:\template.oft")

vItem.Display

Set vItem = Nothing
Set vOL = Nothing
End Sub
If you're using early binding (ie. setting a reference to Outlook), change your Dim statement to:Dim vOL As Outlook.Application, vItem As Outlook.MailItemThough there really is no reason to do it that way unless you want to see the intellisense for the variables