This code is supposed to save the file as PDF to my pc and after that mail the XLSM and PDF file as attachments in an automated mail... but my pdf's dont get saved properly because my code is wrong and I just dont know how to fix it, does anyone know how I can fix it?
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 (Path & filename & ".PDF")
.Display
End With
Set OutlookMail = Nothing
Set outlookapp = Nothing
End Sub