PC Review


Reply
Thread Tools Rate Thread

close all worksheets accept the active one

 
 
S Himmelrich
Guest
Posts: n/a
 
      15th Jan 2008
I've not seen anything on this, but would like to close all opened
worksheets accept the one that is current active - any thoughts on
this?
 
Reply With Quote
 
 
 
 
Susan
Guest
Posts: n/a
 
      15th Jan 2008
you mean close all other workBOOKS?
you can't close worksheets............

i would think it would be relatively simple - something like

for each workbook in excel.workbooks
if workbook.active=false then
OR if isnot activeworkbook then
(or something like that)
workbook.close
end if
next workbook

(this is just off the top of my head & syntax is probably terribly
wrong).
hth
susan


On Jan 15, 3:20*pm, S Himmelrich <himmelr...@gmail.com> wrote:
> I've not seen anything on this, but would like to close all opened
> worksheets accept the one that is current active - any thoughts on
> this?


 
Reply With Quote
 
XP
Guest
Posts: n/a
 
      15th Jan 2008
One way:

Call the function below like so (use true or false to save each one or not):

Sub Test()
Call FilesDeActivate(False)
End Sub


Public Function FilesDeActivate(argSaveChanges As Boolean)
Dim wrkBooks As Workbooks
Dim wrkBook As Workbook
Set wrkBooks = Application.Workbooks
For Each wrkBook In wrkBooks
If UCase(wrkBook.Name) <> UCase(ThisWorkbook.Name) Then
Workbooks(wrkBook.Name).Close SaveChanges:=argSaveChanges
End If
Next wrkBook
End Function


"S Himmelrich" wrote:

> I've not seen anything on this, but would like to close all opened
> worksheets accept the one that is current active - any thoughts on
> this?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Before Close Event Hide all Worksheets then Close Application RyanH Microsoft Excel Programming 0 24th Jan 2008 03:15 PM
why do all excel worksheets/workbooks close when I close one? =?Utf-8?B?UGVubnk=?= Microsoft Excel Misc 1 29th Nov 2006 03:49 AM
Excel shoud not close all active books when clicking close button =?Utf-8?B?dGVjaG5vbWlrZQ==?= Microsoft Excel Misc 0 10th Jun 2005 05:35 PM
excel - Windows close button (x) should only close active workboo. =?Utf-8?B?Q29mZmVlQWRpY3Q=?= Microsoft Excel Setup 3 8th Feb 2005 04:30 AM
Accept Active X Diane Windows XP Print / Fax 1 25th Feb 2004 03:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:35 PM.