ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sace and close (https://www.excelbanter.com/excel-programming/291028-sace-close.html)

ianripping[_35_]

Sace and close
 
I want to have a macro assigned to a button so that when the button is
pressed the current file is saved and then excel is exited.

I tried: -

Sub Closea()
ThisWorkbook.Save
Application.Select.Close
End Sub

But no good. Saving works but not close.

Sub Closea()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

Will close the workbook but not excel itself.
Any ideas?


---
Message posted from http://www.ExcelForum.com/


arno

Sace and close
 
application.quit


Application.Select.Close



arno



Beto[_3_]

Sace and close
 
ianripping < wrote:

I want to have a macro assigned to a button so that when the button is
pressed the current file is saved and then excel is exited.

I tried: -

Sub Closea()
ThisWorkbook.Save
Application.Select.Close
End Sub

But no good. Saving works but not close.


To close use Application.Quit

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.


ianripping[_36_]

Sace and close
 
OK Brilliant this works fine, is it possible to make excel save change
to all open workbooks instead of: -

ThisWorkbook.Sav

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Sace and close
 
Hi
try
For Each w In Workbooks
w.save
Next w

Frank

OK Brilliant this works fine, is it possible to make excel save
changes to all open workbooks instead of: -

ThisWorkbook.Save


---
Message posted from http://www.ExcelForum.com/



ianripping[_37_]

Sace and close
 
Thanks Frank. Works great. Not too sure how it does but it does

--
Message posted from http://www.ExcelForum.com


ianripping[_38_]

Sace and close
 
Thanks Frank. Works great. Not too sure how it does but it does

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com