ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CLOSE ALL macro for XL2K (but with prompt to save for each file)? (https://www.excelbanter.com/excel-programming/336905-close-all-macro-xl2k-but-prompt-save-each-file.html)

StargateFan[_3_]

CLOSE ALL macro for XL2K (but with prompt to save for each file)?
 
Word's CLOSE ALL isn't as nice as WP's - where a small box appears and
you just tick to save or not in a box under each column whether or not
to save for each open file - but it still is good in that it prompts
you before closing each file. I searched yesterday for VB code for
Excel and it seems that there are only 2 kinds: either you save all
files or save none, arbitrarily, while closing all. This isn't good.
Is there code anywhere that prompts for each open file whether or not
to save each one before closing all open workbooks? Tx.


Tom Ogilvy

CLOSE ALL macro for XL2K (but with prompt to save for each file)?
 
Dim ans as Boolean
for each bk in Workbooks
if bk.Name < thisworkbook.Name then
' code to prompt - put results in boolean variable ans
bk.Close SaveChanges:=ans
end if
Next
Application.Quit

--
Regards,
Tom Ogilvy

"StargateFan" wrote in message
...
Word's CLOSE ALL isn't as nice as WP's - where a small box appears and
you just tick to save or not in a box under each column whether or not
to save for each open file - but it still is good in that it prompts
you before closing each file. I searched yesterday for VB code for
Excel and it seems that there are only 2 kinds: either you save all
files or save none, arbitrarily, while closing all. This isn't good.
Is there code anywhere that prompts for each open file whether or not
to save each one before closing all open workbooks? Tx.




Dave Peterson

CLOSE ALL macro for XL2K (but with prompt to save for each file)?
 
Do you want to quit excel?

If yes, I used this line:

application.quit

And got prompted to save any workbooks that were changed.



StargateFan wrote:

Word's CLOSE ALL isn't as nice as WP's - where a small box appears and
you just tick to save or not in a box under each column whether or not
to save for each open file - but it still is good in that it prompts
you before closing each file. I searched yesterday for VB code for
Excel and it seems that there are only 2 kinds: either you save all
files or save none, arbitrarily, while closing all. This isn't good.
Is there code anywhere that prompts for each open file whether or not
to save each one before closing all open workbooks? Tx.


--

Dave Peterson


All times are GMT +1. The time now is 05:13 PM.

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