Hi all,
I'm trying to get an excel file to save as pdf to a specific location
after which I want it to open up outlook and email a message to a predefine location.
I have been able to save the file using the details in a specific cell as the file name and save to a temp directory.
What I can't work out is how to get this PDF file to then open an outlook email template and send the clean up the pdf file.
Ideally I'd like the file name to be in the subject.
I found this code for the email side of things and have modified a few details as to the send to, part of the subject but I am unable to work out what part to change for my dynamic file name to work.
I was trying to define it by using the string "fName" but then I couldn't save the file at all.
I'm trying to get an excel file to save as pdf to a specific location
after which I want it to open up outlook and email a message to a predefine location.
I have been able to save the file using the details in a specific cell as the file name and save to a temp directory.
Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:="C:\Temp\" & Range("B10").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
What I can't work out is how to get this PDF file to then open an outlook email template and send the clean up the pdf file.
Ideally I'd like the file name to be in the subject.
I found this code for the email side of things and have modified a few details as to the send to, part of the subject but I am unable to work out what part to change for my dynamic file name to work.
I was trying to define it by using the string "fName" but then I couldn't save the file at all.
Code:
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
'.To = "tyers@mquarry.com.au"
.To = "austtech@aussiebb.com.au"
.Subject = "Customer WOrk Order - "
.Body = "How do I get the PDF to attach correctly??"
.Attachments.Add ("C:\Temp\" & fName & ".pdf")
.Send
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
.Subject = "Test"
.Body = "How do I get the PDF to attach correctly??"
.Attachments.Add ("C:\Users\Documents\Diagnostic\" & fName & ".pdf")
.Send