Hi, I'm trying to get Excel 2010 to save a worksheet as a PDF (using same filepath as workbook), then attach the PDF to a new email. The 'to' email address and 'subject' reference specific cells. Everything works as desired, EXCEPT I can't get the PDF to attach.
This is a mix of different code I've found online, but I'm not sure why it won't attach.
I've also been tinkering with Ron de Bruin's page (http://www.rondebruin.nl/mail/outloo...emplatepdf.htm), but I really don't want to have an extra worksheet if possible.
How can amend the code below to get this rocket to fly? Otherwise, what other code can I use?
Sub EMAIL_AS_PDF()
'
' EMAIL_AS_PDF Macro
'
'
ThisFile = Range("Agreement!N13").Value & " Agreement"
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ActiveWorkbook.Path & "\" & ThisFile & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Range("BE21")
.Subject = Range("N13") & " Project Agreement"
.Body = ""
.Attachments.Add FileNamePDF
If Send = True Then
.Send
Else
.Display
End If
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I've ran a search on this subject, but came up pretty empty handed.
Thanks for the help!
Bookmarks