I have a macro that e-mails a form to recipients. The macro creates a hard-disc folder and saves to it so that the info on the form can be mailed. It is for use on an intranet.
what I would like to do is to delate the saved file and it’s folder from the hard-disc after use. However if I clase the doc after the e-mail the sub stops as well. The macro is below (with many thanks to Chris Rae and lots of tips from this forum).
Any ideas please?
Sub MailDoc()
If Len(Dir(“c:hold_file”, vbDirectory)) > 0 Then
Else
MkDir “c:hold_file”
End If
ChangeFileOpenDirectory “C:hold_file”
Kill “C:hold_file*.*”
ActiveDocument.SaveAs FileName:=”bsg401.doc”
Dim myOutlook As Object
Dim myMailItem As Object
‘ Make instance
Set myOutlook = CreateObject(“Outlook.Application”)
‘ Make mail item
Set myMailItem = myOutlook.createitem(0)
‘ Set recipient (internal mail)
myMailItem.Recipients.Add “solomon, david”
‘myMailItem.Recipients.Add “Pearce, Muriele
‘ Set subject
myMailItem.Subject = “Starters & Leavers – Leakage Contractors”
‘ Set body
myMailItem.body = “The attached form BSG 401 contains Leakage Contractor personnel details for your attention.”
‘ Set open doc as attachement
myMailItem.Attachments.Add ActiveDocument.FullName
‘ And send it!
myMailItem.send
‘ Close instance
Set myOutlook = Nothing
sent_message.Show
End Sub