Hey all I am having a bit of trouble with my VBA code. I added a new grouping of code that saves one of my open windows (TEST5.csv) to a new folder with a new name and then closes TEST5.csv. It then deletes the original file: TEST5.
Prior to introducing this code my windows all closed perfectly and the application quit.
Now the windows all close but the application remains open... Any ideas?
Code is below, new stuff is in the blue.
Prior to introducing this code my windows all closed perfectly and the application quit.
Now the windows all close but the application remains open... Any ideas?
Code is below, new stuff is in the blue.
Code:
Sub CloseWorkBook()
' Saving Output file and Closing all open windows.
'
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\Output\TEST5_" & _
Format(Now(), "mm_dd_yyyy hh mm AMPM"), FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWindow.Close
[COLOR=blue]'test script[/COLOR]
[COLOR=blue]Windows("TEST5.csv").Activate
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\Unedited_Csv\TEST5-UNEDITED_" & _
Format(Now(), "mm_dd_yyyy hh mm AMPM"), FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
Kill ThisWorkbook.Path & "\TEST5.csv"
ActiveWindow.Close
[/COLOR]Application.DisplayAlerts = True
ActiveWindow.Close
Application.Quit
End Sub