Getting this error every time. The code is correct. Was working yesterday. Now, it is not. Stumped.
VBA Code:
Public Sub Save_Range_As_PDF_and_Send_Email()
Dim PDFrange As Range
Dim PDFfile As String
Dim toEmail As String, emailSubject As String
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
With ActiveWorkbook
Set PDFrange = .ActiveSheet.Range("A1:I53").Value
toEmail = .ActiveSheet.Range("B15").Value
emailSubject = .ActiveSheet.Range("C6").Value
PDFfile = Replace(.FullName, ".xlsx", ".pdf")
End With
PDFrange.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'Send email with PDF file attached
Set OutApp = New Outlook.Application
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = toEmail
.Subject = emailSubject
.Body = "Please see attached PO. We look forward to your response and collaboration. Do not hesitate to reach out with any questions. Thank you."
.Attachments.Add PDFfile
.send
End With
'Delete the temporary PDF file
Kill PDFfile
Set OutMail = Nothing
Set OutApp = Nothing
End Sub