Info

Public Const CONTROLNAME As String = "Close && De&lete"

Private Sub CloseAndKill() Dim tmpAnswer As Variant

If ActiveWorkbook Is Nothing Then Exit Sub tmpAnswer = MsgBox("Are you sure you want to delete &

ActiveWorkbook.FullName & ?", _

vbYesNoCancel + vblnformation)

If tmpAnswer = vbYes Then

Dim tmpFileName As String Dim RecentFle As RecentFile tmpFileName = ActiveWorkbook.FullName

'this removes the file from the recent used list so 'that you don't accidentally try to open it again For Each RecentFle In Application.RecentFiles

If RecentFle.Path = tmpFileName Then RecentFle.Delete

Next

ActiveWorkbook.Close SaveChanges:=False

On Error Resume Next

Kill tmpFileName 'deletes the file

MsgBox "Unable to delete & tmpFileName & "

End If End If End Sub

0 0

Post a comment