Good morning
Ive come across this VBA to send a worksheet as a pdf.
How would i change the code to add in a range to send as the email.
Source = Range("A1:K38")
mank thanks
Ive come across this VBA to send a worksheet as a pdf.
How would i change the code to add in a range to send as the email.
Source = Range("A1:K38")
mank thanks
VBA Code:
Sub Email_From_Excel_Basic()
Dim emailApplication As Object
Dim emailItem As Object
Dim strPath As String
' Build the PDF file name
strPath = ActiveWorkbook.Path & Application.PathSeparator & "Sheet1.pdf"
' Export workbook as PDF
Worksheets("Sheet1").ExportAsFixedFormat xlTypePDF, strPath
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
' Now we build the email.
emailItem.To = "*** Email address is removed for privacy ***"
emailItem.Subject = "Subject line for the email."
emailItem.Body = "The message for the email."
' Attach the PDF file
emailItem.Attachments.Add strPath
' Send the Email
' Use this OR .Display, but not both together.
emailItem.Send
' Display the Email so the user can change it as desired before sending it
' Use this OR .Send, but not both together.
'emailItem.Display
Set emailItem = Nothing
Set emailApplication = Nothing
' Delete the PDF file
Kill strPath
End Sub