This is a version of the macro and userform from Select from a list of subjects before sending a message and uses a userform to display a list of templates to select from to create a new message to the selected contact.
Create the Userform
- Right click on Project1 and select Insert > UserForm
- Open the control Toolbox and select a ComboBox and add it to the UserForm.
- Add a Command button.
- Right click on the Command button and choose Properties.
- Type OK (or Use Template) in the Caption field.
- Type btnOK in the (Name) field.
- Right click on the UserForm and choose View Code.
- Paste the code below into the code window.
- Change the Template display names as desired. This list is for your reference only, not the actual template file name. The filename is set in the VBA macro code.
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Potential client"
.AddItem "New client welcome letter"
.AddItem "Work order approval"
.AddItem "Existing client"
.AddItem "Payment overdue"
.AddItem "Invoice"
End With
End Sub
Private Sub btnOK_Click()
lstNum = ComboBox1.ListIndex
Unload Me
End Sub
Macro to call the UserForm
- Right click on Project1 and choose Insert > Module.
- Paste the code below into the Module.
- Change the template filenames in strTemplate.
Select a contact then run the macro to test it.
Public lstNum As Long
Public Sub ChooseTemplate()
Dim oMail As Outlook.MailItem
Dim oContact As Outlook.ContactItem
If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = ActiveExplorer.Selection.Item(1)
Dim strTemplate As String
UserForm1.Show
Select Case lstNum
Case -1
' -1 is what you want to use if nothing is selected
strTemplate = "template-1"
Case 0
strTemplate = "template-1"
Case 1
strTemplate = "template-2"
Case 2
strTemplate = "template-3"
Case 3
strTemplate = "template-4"
Case 4
strTemplate = "template-5"
End Select
strTemplate = "C:\Users\me\Templates\" & strTemplate & ".oft"
Set oMail = Application.CreateItemFromTemplate(strTemplate)
With oMail
.To = oContact.Email1Address
.ReadReceiptRequested = True
.Subject = "My Macro test"
.Body = "Hi " & oContact.FirstName & "," & vbCrLf & vbCrLf & oMail.Body
.Display
End With
End If
Set oMail = Nothing
End Sub
Video tutorial
Create a toolbar button
You can create a ribbon or QAT button for the ChooseTemplate macro so it's easier to start the macro.



