DominicBell
New Member
- Joined
- Jan 27, 2015
- Messages
- 2
Hi all,
Not a Macro genius so will likely need a bit of guidance here. I'm trying to get a macro running whereby when our users click the button to run it, the file then attaches to an email with a new name convention (data from cell A2 & original file name), the email needs to then automatically send via outlook to me.
I can't save the file because it will save to different locations of each user, so i need this to be more on the hop.
The code i am using at the minute is below, and i think my issue is around the section that says ".Attachments.Add ActiveWorkbook.FullName"
Thanks all for the help in advance!
Dom
Not a Macro genius so will likely need a bit of guidance here. I'm trying to get a macro running whereby when our users click the button to run it, the file then attaches to an email with a new name convention (data from cell A2 & original file name), the email needs to then automatically send via outlook to me.
I can't save the file because it will save to different locations of each user, so i need this to be more on the hop.
The code i am using at the minute is below, and i think my issue is around the section that says ".Attachments.Add ActiveWorkbook.FullName"
Code:
Sub Mail_Workbook_1()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "Email.Address@send.com"
.CC = ""
.BCC = ""
.Subject = "This is a test"
.Body = "Hello World!"
.Attachments.Add ActiveWorkbook.FullName
' I want to re name the workbook, without saving it, how do i do this?
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Thanks all for the help in advance!
Dom