Solved

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

Posted on 2014-01-16
2
4,230 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
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now