Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-16
2
Medium Priority
?
5,238 Views
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 ?

Regards
Toco
0
Comment
Question by:Tocogroup
[X]
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
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39785255
Hi,

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)

    .Display

End With

End Sub

Open in new window

Regards
0
 

Author Comment

by:Tocogroup
ID: 39785299
Excellent. Thanks for that.

Toco
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

670 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