The VBA was created to send bulk emails with a word template as the outlook body. When I run the macros I get compile error: variable not defined message. It is referring to the portion with the Editor. How would I go about defining the variable? The code is listed below.
Rich (BB code):
Sub sendMail()
Dim ol As Outlook.Application
Dim olm As Outlook.MailItem
Dim wd As Word.Application
Dim doc As Word.Document
Set ol = New Outlook.Application
'start from row 11 and go to the last row with data
Dim r As Integer
For r = 11 To Sheet4.Cells(Rows.Count, 1).End(xlUp).Row
Set olm = ol.CreateItem(olMailItem)
Set wd = New Word.Application
Set doc = wd.documents.Open(Cells(6, 2).Value)
With wd.Selection.Find
.Text = "<<first name>>"
.Replacement.Text = Sheet4.Cells(r, 2).Value
.Execute Replace:=wdReplaceAll
End With
doc.Content.Copy
With wd.Selection.Find
.Text = "<<vendor>>"
.Replacement.Text = Sheet4.Cells(r, 3).Value
.Execute Replace:=wdReplaceAll
End With
With wd.Selection.Find
.Text = "<<amount>>"
.Replacement.Text = Sheet4.Cells(r, 4).Value
.Execute Replace:=wdReplaceAll
End With
'Set the properties of the mail item, to, cc, subject, etc...
With olm
.Display
.To = Sheet4.Cells(r, 5).Value
.Subject = Sheet4.Cells(r, 6).Value
'Copying the information from the word document into the body of the email
Set Editor = .GetInspector.WordEditor
Editor.Content.Paste
'.Send
End With
Set olm = Nothing
Application.DisplayAlerts = False
doc.Close SaveChanges:=False
Set doc = Nothing
wd.Quit
Set wd = Nothing
Application.DisplayAlerts = True
Next
End Sub