#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default closeall

i have the following simple program to save all programs
(the first one). i now want the program to close all
sheets. i realize that there is the 'application.quit'
function, but i dont want to close EXCEL. the problem
with the second program below is that the first sheet is
the one with the program, once it closes the prgram
obviously stops. im sure there are many ways of doing
this...

For Each w In Application.Workbooks: w.Save
Next w

For Each w In Application.Workbooks: w.Close
Next w
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default closeall

For Each w In Application.Workbooks
If w.name<thisworkbook.name Then w.Close
Next

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default closeall

For Each w In Application.Workbooks
w.Save
If w.Name < ThisWorkbook.Name Then
w.Close
End If
Next w

ThisWorkbook.Close


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Dumbass" wrote in message
...
i have the following simple program to save all programs
(the first one). i now want the program to close all
sheets. i realize that there is the 'application.quit'
function, but i dont want to close EXCEL. the problem
with the second program below is that the first sheet is
the one with the program, once it closes the prgram
obviously stops. im sure there are many ways of doing
this...

For Each w In Application.Workbooks: w.Save
Next w

For Each w In Application.Workbooks: w.Close
Next w



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"