At the moment my code works like this: when you click on play it automatically saves the file to PDF, then it opens the mail itself with a title, etc and also with a XLSM file. now I want it to add the same file as PDF instead of XLSM.. how do I do that if the title of the PDF is the cellname Range ("39")?
this is my code:
this is my code:
Code:
Sub saveandsend()
Dim Path As String
Dim filename As String
Path = "C:\Users\Erik Stoeken\Documents\van Wijk\Excel test\"
filename = Range("P39")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsm"
' SendEmail Macro
'
Dim outlookapp As Object
Dim OutlookMail As Object
Set outlookapp = CreateObject("Outlook.Application")
Set OutlookMail = outlookapp.CreateItem(0)
On Error Resume Next
With OutlookMail
.To = "erikstoeken@gmail.com"
.CC = ""
.BCC = ""
.Subject = Range("X22")
.Body = "Bon zit in de bijlage."
.Attachments.Add Application.ActiveWorkbook.FullName
.Attachments.Add tempPDFFileName
.Display
End With
Set OutlookMail = Nothing
Set outlookapp = Nothing
End Sub