Excel macro to send emails using template in Ms Word

In our earlier posts, we explained how to recreate mail merge functionality using vba in word to equip with few additional features.

In this post, we are developing same logic in excel. Here's a sample code. You can tweak it as required. And feel free to write to me in case you face any trouble while tweaking.


Considering the word document template as:


And data in excel as:


Sub Word()

Dim wd As Word.Application

Dim olApp As Outlook.Application

Dim Omail As Outlook.MailItem

Dim wddoc As Document

Set wd = New Word.Application

Set wddoc = wd.Documents.Open("C:\ABC.docx")

For i = 2 To 5

Set olApp = New Outlook.Application

Set Omail = olApp.CreateItem(olMailItem)

 With Omail

     .To = "abc.def@xxx.com"

     .Subject = "I love XtremeExcel's Youtube Channel"

     .Body = wddoc.Content

 For x = 1 To 2

 .Body = Replace(.Body, "_" & x & "_", Sheets(1).Cells(i, x).Value)

 Next

 .Send

 End With

Next

End Sub