Deleting a File - Help ASAP

poleary2000

Active Member
Joined
Apr 1, 2002
Messages
354
I am using the following code to send an e-mail. Basically, it copies the cells from a worksheet in the original workbook, opens a new workbook, pastes the information, saves the file and attaches to an Outlook message.

To attach the file, I had to first save the file to the harddrive. What I would like to do is delete the file after the ActiveWorkbook.Close? Can someone help ASAP

Cells.Copy

Set newBook = Workbooks.Add

Cells.PasteSpecial

With newBook
.SaveAs Filename:="blah blah blah"
End With

Dim olApp As Object, olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
olMail.To = strRecipients
olMail.Subject = "blah blah"
olMail.Body = "blah blah"
olMail.Attachments.Add ActiveWorkbook.FullName
olMail.Display

ActiveWorkbook.Close SaveChanges:=False
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Help ASAP nearly put me off but try:

Kill "blah blah blah"

where "blah blah blah" is the Filename you used in your SaveAs statement.
 

poleary2000

Active Member
Joined
Apr 1, 2002
Messages
354
Thanks for the prompt reply.

I try to never use ASAP or 911, however the last few posts I have made have received no response.

Thanks for your help. I'll try it out.
 

Forum statistics

Threads
1,144,150
Messages
5,722,796
Members
422,459
Latest member
Chriselff

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
Top