Hello,
I would like to be able to send the active workbook using Outlook automatically with VBA. I have the following code, that works fine IF the workbook has already been saved. I want this to work regardless if the workbook has or has not been saved. Example of a not saved workbook would be: Co-worker asks me to provide data, that I don't really care about...so in Excel I simply click File, New Blank workbook which is called Book1 (not saving it) I then do my thing requested. Again, the following code only works if I save the file.
If I run this code when the active workbook has previously been saved somewhere on my drive/network it works perfectly. However it crashes if it has not been saved. The following error message occurs:
Run-Time error
Cannot fine this file. Verify the path and file name are correct.
and when I click on debug. the following line appears to be the problem: .Attachements.Add Activeworkbook.FullName
Thank you!
I would like to be able to send the active workbook using Outlook automatically with VBA. I have the following code, that works fine IF the workbook has already been saved. I want this to work regardless if the workbook has or has not been saved. Example of a not saved workbook would be: Co-worker asks me to provide data, that I don't really care about...so in Excel I simply click File, New Blank workbook which is called Book1 (not saving it) I then do my thing requested. Again, the following code only works if I save the file.
VBA Code:
Sub EmailtoAssociate
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "Associatesemail"
.Subject = Activeworkbook.name
.Attachements.Add Activeworkbook.FullName
.Send
End With
End Sub
If I run this code when the active workbook has previously been saved somewhere on my drive/network it works perfectly. However it crashes if it has not been saved. The following error message occurs:
Run-Time error
Cannot fine this file. Verify the path and file name are correct.
and when I click on debug. the following line appears to be the problem: .Attachements.Add Activeworkbook.FullName
Thank you!