VBA Save_Email_Delete Sheet

csimonds

Board Regular
Joined
Oct 2, 2011
Messages
73
Hi, I have a workbook that I would like to save a copy in a particular folder with naming.
I would then like to email it, and then close the file.
I have used the below macro for this, however users are receiving an error on line:
Code:
  With Destwb
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
when using this workbook.

Could you please assist me with what is wrong with this code?

Thank you, C

Code:
'Save the new workbook/Mail it/Delete it    TempFilePath = "\\10.1.1.0\Data\#Change Requests\01.Unapproved" & "\"
    TempFileName = "Pricing Request " & Format(Now, "dd-mmm-yy hh-mm")


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    With Destwb
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
        On Error Resume Next
        With OutMail
            .to = "someone@email.com"
            .CC = ""
            .BCC = ""
            .Subject = "New Price Request : " & Format(Now, "dd-mmm-yy hh-mm")
            .Body = "Please find attached new Price Request."
            .Attachments.Add Destwb.FullName
            .Send
        End With
        On Error GoTo 0
        .Close savechanges:=False
    End With
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi, I have a workbook that I would like to save a copy in a particular folder with naming.
I would then like to email it, and then close the file.

Could you please assist me with what is wrong with this code?

Thank you, C


Firstly, please post your code in full, otherwise it's difficult to know what's causing the error.

Secondly, please confirm the intention of your macro. My understanding is the macro will:

1) Save a copy of this workbook into a temporary folder, using the specified naming convention;
2) Send a the saved copy to a recipient via e-mail; and
3) Delete the saved copy from the temporary folder.

Is this correct?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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