I have a number of differrent workbook books with different codes which attach a workbok or a worksheet as a pdf to outlook email to send, everything works fine up till the point when i go to click send in outlook i get the error message unable to perform operation because object has been deleted however the object hasnt. this problem has only occured recently as we have been using similar code before and it worked.
we have opened outlook in safe mode and it works. so i think the problem lays with outlook
i have attached my code for the pdf converter macro
Option Explicit
Sub EmailPDF()
Dim strNewFolderName As String
Dim sh As Worksheet
Dim wb As Workbook
Dim OutApp As Object
Dim OutMail As Object
Dim sPDF_Name As String
Dim sFilePath As String
Dim sFileName As String
Sheets("ASM Report").Select
sPDF_Name = sFilePath & sFileName & ".pdf"
sPDF_Name = "C:\" & Range("C5").Value & " " & "ASM Report" & " " & Range("m4").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=sPDF_Name, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = Range("C5").Value & " " & "ASM Report" & " " & Range("m4").Value & ".pdf"
.Body = " "
.Attachments.Add sPDF_Name
.Display
End With
End Sub