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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,462
Members
448,965
Latest member
grijken

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