Macro VBA Application not quitting with code?

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
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.


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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top