PDA

View Full Version : Saving & closing



Gil
03-12-2016, 06:35 AM
Hello
I am using this code to close my excel file & it works successfully.


Private Sub CommandButton1_Click()
Dim Path As String
Dim FileName1 As String
Dim FileName2 As String
Path = "C:\Users\Andy's\Documents\Risk Assessments\"
FileName1 = Range("M8")
FileName2 = Range("B35")
ActiveWorkbook.SaveAs FileName:=Path & FileName1 & "-" & FileName2 & ".xls", FileFormat:=xlNormal
ActiveWorkbook.Close

End Sub

My problem is that I am left with this instance of excel which I have to close manually, is there a bit of code I can insert to close it.

Paul_Hossler
03-12-2016, 07:51 AM
Add this to the end



Application.Quit

Gil
03-12-2016, 09:07 AM
Hello Paul
Thank you for the reply, it still won't close. I will have to put it into a workbook and repost if I don't get anywhere with it.