Re-Naming an Attachment in Outlook without Saving the file

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"

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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top