I'm trying to create a .pdf file from an Excel file and attach it to an email. I can create the .pdf, but the .xls file attaches to the email instead.
Sub PDFMAIL()
'
' PDFMAIL Macro
' Creates a .pdf file of the first tab of the worksheet and attaches it to an email
'
Dim CurrentInvoice As String
CurrentInvoice = Worksheets("Invoice").Range("F8").Value
myPDFFilename = "4923 Invoice " & CurrentInvoice & ".pdf"
ActiveSheet.Unprotect
myDir = "C:\Users\sbernard\My Documents\Invoices"
If Dir(myDir & "\" & myPDFFilename) = "" Then
'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\sbernard\Documents\Invoices\" & myPDFFilename, Quality:= _
xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Application.Dialogs(xlDialogSendMail).Show
Else
GoTo 100
100
End
End If
End Sub
Bookmarks