I'm am looking for a way to make a file commit suicide.
I have a requirement to process a file.
When certain cells are filled in, the file is said to be complete. What the user wants to do is rename the file and put it in another directory and remove the original file.
Copying the file to the directory with the new name is not an issue. The problem is getting rid of the file that's still running.
I'm fairly certain that this is impossible without invoking another workbook that saves the file that calls it, closes that file and then moves it.
Here is the appropriate part of the code. SavePath and SaveFile are defined.
The code doesn't like the Kill statement.![]()
If DeleteFlag = True Then ThisWorkbook.Save Savefile = Replace(ThisWorkbook.Name, ".xlsb", "") Savefile = Savefile & " Complete.xlsb" ' Get rid of the copy to file if it exists. If Dir(SavePath & "\" & Savefile) <> "" Then Kill SavePath & "\" & Savefile End If FileCopy ThisWorkbook.Path & "\" & ThisWorkbook.Name, SavePath & "\" & Savefile Kill ThisWorkbook.Path & "\" & ThisWorkbook.Name End I
Bookmarks