I have already set up a macro that auto saves when closing Excel, that way if someone is in a hurry to leave work and they forget to hit save and just close it down, it will save.
I'm stuck at Automatically sending an email that attaches the current workbook.
First of all, is it possible to have both kinds of macros run at the same time when closing Excel?
If yes, here's the coding I have come up with, but it just doesn't complete the task. (Outlook is set up and ready to go)
Also, I want it to automatically email and the user not have to do anything on their end.
I'm not 100% positive the first line of code is correct. I changed the email address for this thread.
Thanks for any input you give.
Sub BeforeClose(Cancel As Boolean)
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
emailItem.to = "test email address"
emailItem.Subject = "DSR"
emailItem.Body = "Test email"
emailItem.Attachments.Add ActiveWorkbook.FullName
emailItem.Send
Set emailItem = Nothing
Set emailApplication = Nothing
End Sub
Bookmarks