PDA

View Full Version : Solved: Close Excel?



Mr.G
01-16-2007, 02:32 AM
What is the code to close Excel ,or can't one close excel with code? I can close the workbook but would like to close the program.
Here is my code for a book.......ActiveWorkbook.Close ("WB name..xls")
Any help please.

Simon Lloyd
01-16-2007, 02:57 AM
Hi its

Application.Quit
I think!

Regards,
Simon

Mr.G
01-16-2007, 03:04 AM
Thanx but that only closes the workbook not excel.

Simon Lloyd
01-16-2007, 03:09 AM
The below is from here http://www.contextures.com/xlfaqMac.html#Close


How do I close a file/close Excel with a macro? http://www.contextures.com/images/scrollup.gif (http://www.contextures.com/xlfaqMac.html#Top)


ActiveWorkbook.Close savechanges:=False 'true ??? --will close the active workbook Workbooks("mywkbk.xls").Close savechanges:=False 'true ??? --will close mywkbk.xls ThisWorkbook.Close savechanges:=False 'true ??? --will close the workbook that holds the code that's running. Application.Quit will close all of Excel. --Be careful with this one.

Regards,

SImon

Mr.G
01-16-2007, 03:17 AM
A ha..... just had put it in the right place
Thanx Simon.

lucas
01-16-2007, 10:12 AM
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
Application.Quit
End Sub
I use this. As Simon points out be careful as it closes without saving changes.

Mr.G
01-16-2007, 11:58 PM
Thanx all