Jeg har en macro i excel, der opretter en opgave i outlook, hvor den gemmer et ark fra filen.
Den opretter fint både kopi af arket og opgave i outlook, men jeg kan ikke få den til at slette (kill) den midlertidige fil igen.
Jeg har vedhæftet koden her... Men hvad skal jeg taste ind for neden for at den sletter filen?
Til at starte med gemte jeg den i samme filnavn, men efter mange oprettelser, så brækker Outlook sig og vil ikke makke ret. Derfor er jeg nødt til at få et nyt filnavn hver gang.,
Kode Sub Create_Task()
'You must set a reference to the Microsoft Object Library x.x via the Tools | Reference...
'in the VB-editor.
Dim olApp As Outlook.Application
Dim olTask As Outlook.TaskItem
Dim CurrFile As String
Set olApp = New Outlook.Application
Set olTask = olApp.CreateItem(3)
ThisWorkbook.Sheets(1).Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & _
Sheets("Grunddata").Range("J13").Value
Application.ScreenUpdating = False
With olTask
.subject = "Serviceaftale, " & Sheets("Grunddata").Range("J13").Value
.Body = "Att.: " & Sheets("Grunddata").Range("J17").Value & ", Tlf: " & Sheets("Grunddata").Range("J16").Value & " / " & Sheets("Grunddata").Range("M17").Value
'You need to change to Your own dateformat.
.DueDate = DateAdd("n", 10080, Now) ' Set the due date to
' X minutes from now.
.StartDate = Sheets("Grunddata").Range("M9").Value
.Status = olTaskNotStarted
.Importance = olImportanceNormal
.ReminderSet = True
.ReminderPlaySound = True
.Companies = "none"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
ActiveWorkbook.Close False
Kill ThisWorkbook.Path & "\" & [U][B]Sheets("Grunddata").Range("J13").Value[/B][/U]
Set olTask = Nothing
Set olApp = Nothing |