Theva
asked on
Delete save as file
Hi Experts,
I would like to request Experts help. How to delete the save as workbook at “ActiveWorkbook.SaveAs ThisWorkbook.path” after the document is delivered via email? Hope Experts could help to add this feature in the attached script.
I would like to request Experts help. How to delete the save as workbook at “ActiveWorkbook.SaveAs ThisWorkbook.path” after the document is delivered via email? Hope Experts could help to add this feature in the attached script.
Function SendMsg(strSubject As String, _
strBody As String, _
strTO As String, _
Optional strDoc As String, _
Optional strCC As String, _
Optional strBCC As String)
Dim oLapp
Dim oItem
Dim myattachments
Dim fs As String
Set oLapp = CreateObject("Outlook.Application")
Set oItem = oLapp.CreateItem(olMailItem)
Application.DisplayAlerts = False
ThisWorkbook.Sheets("Request").Copy
Call deleteButton2
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ThisWorkbook.VBProject.VBComponents("GMT").Export Environ("Temp") & "\GMT.bas"
ActiveWorkbook.VBProject.VBComponents.Import (Environ("Temp") & "\GMT.bas")
ActiveWorkbook.SaveAs ThisWorkbook.path & "\" & Sheets("Request").Cells(1, "i") & "_" & Sheets("Request").Cells(5, "I") & ".xls", FileFormat:=-4143
Application.DisplayAlerts = True
fs = ActiveWorkbook.FullName
ActiveWorkbook.Close
oItem.Subject = strSubject
addr1 = "thv@gmail.com"
oItem.To = addr1 + ";" + addr2 '+ ";" + addr3
oItem.CC = strCC
oItem.BCC = strBCC
'oItem.BodyFormat = olFormatHTML
oItem.htmlbody = strBody
oItem.Importance = olImportanceHigh
oItem.attachments.Add fs
'
oItem.display 'send
Set oLapp = Nothing
Set oItem = Nothing
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oItem.display 'send
' Below is the code added in between ur code starts here
'fs.DeleteFile (Server.MapPath("./XXFolde
'fs.DeleteFile(FilePath)
fs.DeleteFile("\" & Sheets("Request").Cells(1,
'Above is the code added in between ur code ends here
Set oLapp = Nothing
gladson1976
fs is a string. Not the scripting object which is not utilised in this code
Dave
fs is a string. Not the scripting object which is not utilised in this code
Dave
ASKER
Hi,
Thanks for the help.
Thanks for the help.
System.IO.File.Delete(fs);
I'm assuming that the fs string contains the full path and file name of the file you want to delete.
You should put this just before the Set oLapp = nothing command.
regards,
Mike