So this is a piece of code, that runs in a different workbook, as part of the same system, perfectly fine. However will not function as required in this workbook.
This doesn't throw an error, but when hovering over "ActiveWorkbook.FullName" in the .Add code, it shows as <automation error="">
I have literally no idea how to fix this. Previous weeks this code has been working fine, however I am at the point of this project launching and I cannot see for the life of me why the attachment is not adding. I have tried every possible variation of declaring the file to be attached, and all have the exact same issue.
</automation>
This doesn't throw an error, but when hovering over "ActiveWorkbook.FullName" in the .Add code, it shows as <automation error="">
I have literally no idea how to fix this. Previous weeks this code has been working fine, however I am at the point of this project launching and I cannot see for the life of me why the attachment is not adding. I have tried every possible variation of declaring the file to be attached, and all have the exact same issue.
Code:
Dim FilePath As String
Dim FileName As String
Dim OutApp As Object
Dim OutMail As Object
ActiveSheet.Copy
Sheets(MON).Protect Password = NOMINAL PASSWORD HERE
FilePath = FILEPATH
FileName = FILENAMEincEXT
ActiveWorkbook.SaveAs FileName:=FilePath & FileName
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = EMAILSTRING
.CC = EMAILSTRING2
.BCC = ""
.Subject = SUBJ
.Body = "BODY HERE"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
On Error GoTo 0
ActiveWorkbook.Close savechanges:=False
Set OutMail = Nothing
Set OutApp = Nothing