VBA Macro used in the Microsoft Office Outlook Application

Open Email Templates

Share on facebook
Share on twitter
Share on linkedin
Outlook Email templates are great! Opening Outlook email templates not so great. That is why we create the Open Email Templates macro. This Outlook macro will help you quickly access your default email template file path giving you access to all of your created Outlook Email Templates. An Input Box will appear with all of your available email templates with a unique leading number. Simply type the leading number of the email template you want to display and click to Ok to open it. This Outlook macro is designed to grow with you over time and will display all of your email templates as you continue to create them. The Open Email Templates macro puts your email templates at your fingertips. Stop spending time opening email template and start using them efficiently and effectively today!

See it in Action!

Watch this video to see this macro in action.

The Code

Here is the code behind this macro.
'Leverage & Lean "Less Clicks, More Results"
Sub OpenEmailTemplates()
' Means variable is in use
Dim Counter As Integer '
Dim DisplayFiles As String '
Dim FolderPath As String '
Dim NewItem As Outlook.MailItem '
Dim oFSO As Object '
Dim oFolder As Object '
Dim oFile As Object '
Dim TemplateName As String '
Dim TemplateNumber As Integer '
Dim User As String '

On Error GoTo LeverageLean

User = (Environ$("Username"))
FolderPath = "C:\Users\" & User & "\AppData\Roaming\Microsoft\Templates\" 'Default Outlook Email Template path. You can update the FolderPath to somewhere else.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(FolderPath)

Counter = 1
 
For Each oFile In oFolder.Files 'Loop through every File in FolderPath
If oFile.Type = "Outlook Item Template" Then 'If the File is an .oft add to DisplayFiles
DisplayFiles = DisplayFiles & vbNewLine & Counter & ". " & Left(oFile.Name, Len(oFile.Name) - 4)
Counter = Counter + 1
End If
Next oFile

If Len(DisplayFiles) > 1023 Then 'If DisplayFiles exceeds the character limit display MsgBox
MsgBox ("You have exceeded the character limit of the InputBox. " & _
"Email templates that should be available for selection will not be able to display. " & _
"Try making the file names of your email templates shorter. " & _
"Navigate to your folder path here: " & FolderPath)
End If

TemplateNumber = InputBox(DisplayFiles, "Outlook Email Templates") 'Determine what Email Template to open

Counter = 1

For Each oFile In oFolder.Files 'Loop through every File in FolderPath
If oFile.Type = "Outlook Item Template" Then 'If the File is an .oft
If Counter = TemplateNumber Then 'If the Counter is the same as the selected Template
TemplateName = oFile.Name 'Selected Email Template File Name
End If
Counter = Counter + 1
End If
Next oFile
 
Set NewItem = Application.CreateItemFromTemplate(FolderPath & "\" & TemplateName)
NewItem.Display 'Open the selected Email Template path

Set NewItem = Nothing
Set oFSO = Nothing
Set oFolder = Nothing
Set oFile = Nothing

Exit Sub

LeverageLean:
If Err.Number = 76 Then
MsgBox ("Something went wrong. Ensure the Folder Path is correct. " & vbNewLine & "Don't hesitate to email me: brentschneider@leveragelean.com")
ElseIf TemplateNumber = 0 Or TemplateNumber > Counter - 1 Then
Exit Sub
End If

End Sub
'Stay Awesome!

Macro Instructions

Watch this video to get started using this macro.

Customization

These lines of code can be customized to personalize this macro.
18 FolderPath = “C:\Users\” & User & “\AppData\Roaming\Microsoft\Templates\” ‘Default Outlook Email Template path. You can update the FolderPath to somewhere else.
32 If Len(DisplayFiles) > 1023 Then ‘If DisplayFiles exceeds the character limit display MsgBox (You won’t be able to see all of your template selection options. Try making the file names of your templates short to resolve this issue.)

Insider Comments

  Subscribe  
Notify of

Search for Macros here!

Recent Macros

VBA Macro used in the Microsoft Office Outlook Application

Greeting and Goodbye

We are busy, sometimes too busy to type a friendly Greeting and Goodbye in our emails. This Outlook macro automates the entry of a Greeting “Good Morning” or “Hello” at the beginning of your emails. At the end of your email this macro automatically enters a Goodbye “Have a good night!” and “Enjoy your weekend!”. The Greeting and Goodbye macro helps you deliver better customer service and create better connections with your clients!

VBA Macro used in the Microsoft Office Outlook Application

Save Email as Outlook Email Template

It is DONE! You have drafted the perfect email and are prepared to send it. In the back of your mind you know that once you click Send it could be lost forever. Sure, you can try to copy the email to another folder or keep the email in your drafts but this isn’t sustainable in the long run. This is why Leverage & Lean created the Save Email as Outlook Template macro. With one click you can save your masterpiece and build toward your future!

VBA Macro used in the Microsoft Office Excel Application

Copy Multiple Excel Workbooks into One

This is an Excel Macro to copy separate workbooks into one MASTER workbook. The Details tab will serve as a guide for this macro seeing if you only want specific workbooks to be combined or all that exist in the folder. Additionally, you can indicate if you want only the first tab from each workbook to be copied or all of them. This Excel Macro makes it easy to pull multiple sources of information into one MASTER source on a routine basis.

First time using VBA?

The Developer Tab is an additional section of the ribbon when activated allows you access to Visual Basic in Applications like Excel, Outlook, Word.
Setup Now
Once the Developer Tab is available you will have the capability to update your security to allow Macros to run in the current application.
Setup Now
A sub of code is a collection of objects and variables. For the code to successfully run a library of references needs to be set.
Setup Now

Looking for more?

Subscribe as an Insider to receive additional rights.

Contact Us

Looking to improve your computer processes?
Leverage & Lean is here to help!

Copyright © 2019 Leverage & Lean – Uptown Style WordPress theme by GoDaddy