Is there any way to e-mail an opened Excel file as attachment using VBA?
I use the following macro, but a debugger shows up when I run it, because obviously the file is open - so it won't allow it to be sent as attachment.
Sub simpleEmail()
Dim OutApp As Object, MailItem As Object
Set OutApp = CreateObject("Outlook.Application")
Set MailItem = OutApp.CreateItem(0) 'Create Email
MailItem.To = "email.com"
MailItem.Subject = "subject"
MailItem.Body = "body"
MailItem.attachments.Add "file path"
MailItem.send
End Sub
Is there any way around this?