Hey Guys, I currently have code that creates a Term Sheet from multiple Excel Pages and saves it in a specific folder. I'm looking to write code that sends an email with the term sheet I saved as an attachment. Below is the code I have: (Range B5 is file location and Range B4 is the file name - this is the line of code receiving errors.) The email itself works fine, just the attachment. Thanks for any help!
Code:
Sheets("Company Email").Select
Dim objOutlook As Object
Dim objMail As Object
Dim Content As Range
Dim SendTo As String
Dim CC As String
Dim subject As String
Dim RowCC As Integer
Dim RowTo As Integer
Dim RowSubject As Integer
RowTo = WorksheetFunction.Match("TO:", Range("A1:A500"), 0)
RowCC = WorksheetFunction.Match("CC:", Range("A1:A500"), 0)
RowSubject = WorksheetFunction.Match("Subject:", Range("A1:A500"), 0)
Set Content = Range("B9:F9")
SendTo = Range("B" & RowTo)
CC = Range("B" & RowCC)
subject = Range("B" & RowSubject)
Content.Select
Selection.Copy
'send email
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
With objMail
.To = SendTo
.subject = subject
.CC = CC
.Display
.Attachments.Add Range("B5").Value & "\" & Range("B4").Value & ".pdf"
End With
Set wEditor = objOutlook.ActiveInspector.WordEditor
wEditor.Application.Selection.Paste