my goal with this code is to save my file to PDF and as XLSM file to my pc, then after that it gets put in an automated email where the PDF and XLSM file are attachments.
My Problem: since I am just a beginner when it comes to VBA, I dont know what I am doing wrong..
Could you guys tell me what I need to change in my code so my file saves to my pc in PDF and XLSM with the name from cell 39 (Range ''39'')
I have been stuck with this all day...
My Problem: since I am just a beginner when it comes to VBA, I dont know what I am doing wrong..
Could you guys tell me what I need to change in my code so my file saves to my pc in PDF and XLSM with the name from cell 39 (Range ''39'')
I have been stuck with this all day...
Code:
Sub saveandsend()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"C:\Users\Erik Stoeken\Documents\van Wijk\Excel test\(Range "39".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Dim Path2 As String
Dim filename2 As String
Path2 = "C:\Users\Erik Stoeken\Documents\van Wijk\Excel test\"
filename2 = 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