How do I open and edit an Outlook template file within VBA ?

Posted on 2014-01-16
Last Modified: 2014-01-16
Hi All,

I have an Outlook template file (.oft) which I want to open within an Excel VBA procedure and automatically modify some of the text, depending on a value in my spreadsheet.
How do I do this ?

Question by:Tocogroup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 52

Accepted Solution

Rgonzo1971 earned 500 total points
ID: 39785255

pls try

Sub xx()

Dim oApp As Object, oMail As Object

 Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItemFromTemplate("C:\Users\YouTemplateFile.oft")

With oMail
    strFind = "Code:"
    strNew = "Code:" & Cells(4, 3) ' for example
    .HTMLBody = Replace(oMail.HTMLBody, strFind, strNew)


End With

End Sub

Open in new window


Author Comment

ID: 39785299
Excellent. Thanks for that.


Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question