Saving then Delete Workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to save a temp file so that I can send an e-mail then have it
delete when the e-mail is sent? I'm using a macro to send the e-mail.
 
hi,
Try something like this.....
Sub SaveSendDelete()
Dim StrPath As String
Dim StrFileName As String
Dim StrToDelete As String
ChDir "C:\"
ActiveWorkbook.SaveAs Filename:="C:\Book1.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkBook.Close

' your email macro

StrPath = "c:\" ' the folder path
StrFileName = InputBox("Enter File Name")
StrToDelete = StrPath & StrFileName & ".xls"
On Error GoTo Err
Kill StrToDelete
MsgBox ("File " & StrFileName & ".xls" & " deleted!")
Exit Sub
Err: MsgBox "Whao!! ERROR!!! File NOT deleted!!"
End Sub

since i have not seen your email macro....edit above to fit your machine.
worked on my machine. except for the email part. using xp

regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top