Delete (Kill) Active Workbook
Hi,
Here is an example:
Sub Test()
On Error GoTo ErrorHandler
If ActiveWorkbook.Path < "" Then
If Not ActiveWorkbook.ReadOnly Then
ActiveWorkbook.Saved = True
ActiveWorkbook.ChangeFileAccess xlReadOnly
End If
Kill ActiveWorkbook.FullName
End If
Exit Sub
ErrorHandler:
MsgBox "Fail to delete file: " & ActiveWorkbook.FullName
Exit Sub
End Sub
I am not sure it is perfectly all right.
I recommend to close the workbook after deleted.
--
HTH
okaizawa
stefan via OfficeKB.com wrote:
Hi,
I'd like to open an existing file, save it automatically by macro in a
different location with a new file name. This portion i can do. I'd like then
to delete the original, still active/open workbook. Any suggestions?
Thank you,
Stefan
|