I have a macro, some of which is shown below. Basically, I create a new file, set it as wbNew and then save it (as shown). I then attach it to an email, and then close it. What I would like do in addition is to delete the file from my directory. I tried adding a command at the end that said wbNew.delete, but this did not work.
I would appreciate help on this.
Thanks,
MikeG
==========================================================
With wbNew
.SaveAs Filename:=e & ".xlsx"
End With
'Create email
Dim mailAddress As String
Set OutApp = CreateObject("Outlook.Application")
On Error Resume Next
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = a
' .CC = b
.BCC = ""
.Subject = c
.body = d
.Attachments.Add ActiveWorkbook.FullName
.display
End With
wbNew.Close
I would appreciate help on this.
Thanks,
MikeG
==========================================================
With wbNew
.SaveAs Filename:=e & ".xlsx"
End With
'Create email
Dim mailAddress As String
Set OutApp = CreateObject("Outlook.Application")
On Error Resume Next
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = a
' .CC = b
.BCC = ""
.Subject = c
.body = d
.Attachments.Add ActiveWorkbook.FullName
.display
End With
wbNew.Close