I am trying to print a defined print area from a single worksheet, save as a PDF and then email. I have tried, but can't seem to get it to actually send the email. Below is my code. Any help would be much appreciated. It would also be nice if it would save as the active worksheet name. Thank you!
Sub PrintToPDF_Email()
ChDir "C:\Users\turne\Documents"
'Print to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\turne\Documents\Sales Report March.pdf", OpenAfterPublish:=True
'Declare Variables
Dim EmailApp As Object
Dim EmailItem As Object
Dim myAttachments As Object
'Set Variables
Set EmailApp = CreateObject("Outlook.application")
Set EmailItem = EmailApp.CreateItem(0)
Set myAttachments = EmailItem.Attachments
'Specify Email Items and Add Attachment
With EmailItem
.To = "barryturner@cookiesgac.com"
.Subject = "Sales Report of Fruits"
.Body = "Please find the PDF attachment of the Excel file"
.Attachments.Add "C:\Users\turne\Documents\Sales Report March.pdf"
.send
'.Display
End With
Set EmailItem = Nothing
Set EmailApp = Nothing
End Sub
Sub PrintToPDF_Email()
ChDir "C:\Users\turne\Documents"
'Print to PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\turne\Documents\Sales Report March.pdf", OpenAfterPublish:=True
'Declare Variables
Dim EmailApp As Object
Dim EmailItem As Object
Dim myAttachments As Object
'Set Variables
Set EmailApp = CreateObject("Outlook.application")
Set EmailItem = EmailApp.CreateItem(0)
Set myAttachments = EmailItem.Attachments
'Specify Email Items and Add Attachment
With EmailItem
.To = "barryturner@cookiesgac.com"
.Subject = "Sales Report of Fruits"
.Body = "Please find the PDF attachment of the Excel file"
.Attachments.Add "C:\Users\turne\Documents\Sales Report March.pdf"
.send
'.Display
End With
Set EmailItem = Nothing
Set EmailApp = Nothing
End Sub