Macro : Email Worksheet As PDF

karldugan

New Member
Joined
May 10, 2016
Messages
47
Hi all,
I have the below code which saves the current worksheet as a PDF file and then sends the worksheet out, but I would rather it send the PDF, can someone help?
Thanks,
Karl

Dim OutApp As Object
Dim OutMail As Object
Dim saveLocation As String
Set wb1 = ThisWorkbook

saveLocation = "ADDRESS REMOVED" & Range("I4") & ".pdf"

'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=saveLocation

' Create a new Outlook instance
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0) ' 0 represents a mail item

' Compose the email
With OutMail
.To = Range("I12") & "@email.co.uk" ' Replace with the recipient's email address
'.CC =
.Subject = "Purchase Order " & Range("I4") & " : Approved" ' Replace with your email subject
.Body = "Please find attached your approved purchase order."
.Attachments.Add wb1.FullName
.Send
End With

' Clean up
Set OutMail = Nothing
Set OutApp = Nothing

End If
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try replacing...

VBA Code:
.Attachments.Add wb1.FullName

with

VBA Code:
.Attachments.Add saveLocation

Hope this helps!
 
Upvote 0
Solution

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top