New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

VBA Code to close active window after save and exit

Macros, VBA, Excel Automation, etc.

VBA Code to close active window after save and exit

Postby sintek » Fri Dec 11, 2015 4:43 am

Hi All

I have the following code that closes my file but leaves the active excel window open.
What changes can i make that will exit excel totally.

Code: Select all
Sub Save_File()
Application.DisplayAlerts = False
Sheets(6).Visible = False
Dim Path As String
Dim FName1 As String
Dim FName2 As String
Path = "C:\Users\Steven\Desktop\"
FName1 = Range("C3")
FName2 = Range("G3")
ActiveWorkbook.SaveAs Filename:=Path & FName1 & "-" & FName2 & ".xlsx", FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.Quit
ActiveWindow.Close
End Sub


Thank you in advance for your input.
  • 0

sintek
Rookie
 
Posts: 11
Joined: Dec 6, 2015
Reputation: 0
Excel Version: 2007

Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 237 guests