I seem to have forgotten to add the file path it seems. I changed it now.
'PdfFile = destFolder & Sheets("Hotel Booking").Range("C4") & " " & Sheets("Hotel Booking").Range("C11") & " " & "Hotel Booking.pdf"
'to
PdfFile = PdfFile & destFolder & Sheets("Hotel Booking").Range("C4") & " " & Sheets("Hotel Booking").Range("C11") & " " & "Hotel Booking.pdf"
So the complete code for the attachment is
PdfFile = ActiveWorkbook.FullName
i = InStrRev(PdfFile, ".")
If i > 1 Then PdfFile = Left(PdfFile, i - 1)
PdfFile = PdfFile & " " & destFolder & Sheets("Hotel Booking").Range("C4") & " " & Sheets("Hotel Booking").Range("C11") & " " & "Hotel Booking.pdf"
Debug.Print PdfFile
' Export activesheet as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'
'
'
'
.AddAttachment PdfFile
.Send
'
'
Kill PdfFile
Display More
If I run the macro now, it will send the email without any attachments and will give me an error on the line "Kill PdfFile" saying "File not found". The result on the immediate window is "https://d.docs.live.net/5b4e348d0c77a54e/Desktop/School Work/Crew Scheduling with CDO EVA Air BR225 Hotel Booking.pdf".
When I try changing the line
and keep the rest of the code the same, it will give me an error on this line
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
saying "Invalid procedure call or argument". The result on the immediate window is "https://d.docs.live EVA Air BR225 Hotel Booking.pdf". I'm not sure why it doesn't display the full path name. When I created another macro only with the line "Msgbox Activeworkbook.Path", it will display "https://d.docs.live.net/5b4e348d0c77a54e/Desktop/School Work".
When I try running the macro on an unsaved workook, I will get an error on the line
PdfFile = PdfFile & " " & destFolder & Sheets("Hotel Booking").Range("C4") & " " & Sheets("Hotel Booking").Range("C11") & " " & "Hotel Booking.pdf"
saying "Subscript out of range".