Code – Delete active workbook
Sub DeleteActiveWorkbook() If Application.ProtectedViewWindows.Count > 0 Then Application.ActiveProtectedViewWindow.Edit End IfDim xFullName As String xFullName = Application.ActiveWorkbook.FullName ActiveWorkbook.Saved = True Application.ActiveWorkbook.ChangeFileAccess xlReadOnly Kill xFullName Application.ActiveWorkbook.Close False End Sub