Jet Fusion
Member
Hi
Please can someone assist with the following code.
It works if you put in a file name but when you select cancel it gives a runtime error (see attahced and full code). I would like for if you press cancel that it gives a message dialog box with message lets say "Document not sent: whatever the text may be that can be altered.
Thank you in advance
Please can someone assist with the following code.
It works if you put in a file name but when you select cancel it gives a runtime error (see attahced and full code). I would like for if you press cancel that it gives a message dialog box with message lets say "Document not sent: whatever the text may be that can be altered.
Code:
Sub EmailPDF()
fdir = "c:\\temp\\"
FName = InputBox("Please Enter Filename")
fPath = fdir & FName & ".pdf"
With Application
.EnableEvents = True
.ScreenUpdating = False
End With
ToAddress = ""
CCAddress = ""
CCAddress2 = ""
CCAddress3 = CCAddress & "; " & CCAddress2
MailSub = FName & " Issue Slip "
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
fPath, Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=False
Set oOutlookApp = CreateObject("Outlook.Application")
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = ToAddress
.CC = CCAddress3
.Subject = MailSub
oItem.Display
oItem.Attachments.Add fPath
Set OutMail = Nothing
Set OutApp = Nothing
Set fs = CreateObject("Scripting.FileSystemObject")
fs.deletefile fPath
End With
End Sub
Thank you in advance