I'm having trouble with saving the active worksheet as a PDF, sending it as an attachement in an email, and RETAINING the email in a designated folder. Also having trouble having the file name as "worksheet.name" & date ".pdf." I'd like the date added to the end of the name, but can't seem to get it to work. I found this code online, and it's been working ok as far as sending the worksheet as a PDF attachment, but it WILL NOT SAVE in the designated folder! Can someone help.
What I need is..
1) The current date added to the file name (so each new pdf will be saved and not overwritten)
2) The PDF to ACTUALLY be saved and not deleted after attaching/emailing.
Please help!!!
Thanks
Here's what I have....
Sub SendPDF()
Dim strPath As String, strFName As String
Dim OutApp As Object, OutMail As Object
'Create PDF of active sheet only
strPath = Environ$("FILE PATH HERE ex.c:\folder1\folder2\folder3") & Application.PathSeparator & strFName
strFName = ActiveSheet.Name & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "EMAIL ADDRESS HERE"
.CC = ""
.BCC = ""
.Subject = "Supply Order"
.Attachments.Add strPath & strFName
.Send End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
What I need is..
1) The current date added to the file name (so each new pdf will be saved and not overwritten)
2) The PDF to ACTUALLY be saved and not deleted after attaching/emailing.
Please help!!!
Thanks
Here's what I have....
Sub SendPDF()
Dim strPath As String, strFName As String
Dim OutApp As Object, OutMail As Object
'Create PDF of active sheet only
strPath = Environ$("FILE PATH HERE ex.c:\folder1\folder2\folder3") & Application.PathSeparator & strFName
strFName = ActiveSheet.Name & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "EMAIL ADDRESS HERE"
.CC = ""
.BCC = ""
.Subject = "Supply Order"
.Attachments.Add strPath & strFName
.Send End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub