PC Review


Reply
Thread Tools Rate Thread

Close other open excel files

 
 
anon
Guest
Posts: n/a
 
      3rd Oct 2007
HI,

I'd like my wb on opening to close all other excel files that are open
(prompting them to save first).

I'd also like to prevent the user opening any other excel files whilst
my wb is open.

Is this possible (and is it a stupid thing to try and do?)

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      3rd Oct 2007
Easy

for each wbk in workbooks
if wbk.name <> ThisWorkbook.name then
workbooks(wbk.name).close
end if
next wbk

"anon" wrote:

> HI,
>
> I'd like my wb on opening to close all other excel files that are open
> (prompting them to save first).
>
> I'd also like to prevent the user opening any other excel files whilst
> my wb is open.
>
> Is this possible (and is it a stupid thing to try and do?)
>
>

 
Reply With Quote
 
=?Utf-8?B?R3JlZyBILg==?=
Guest
Posts: n/a
 
      9th Nov 2007
How can i modify this to prevent thisworkbook.name and another excel file not
to close? I need the files "Daily Reports.xls" and "NPP_*" to stay open.
Thanks

"Joel" wrote:

> Easy
>
> for each wbk in workbooks
> if wbk.name <> ThisWorkbook.name then
> workbooks(wbk.name).close
> end if
> next wbk
>
> "anon" wrote:
>
> > HI,
> >
> > I'd like my wb on opening to close all other excel files that are open
> > (prompting them to save first).
> >
> > I'd also like to prevent the user opening any other excel files whilst
> > my wb is open.
> >
> > Is this possible (and is it a stupid thing to try and do?)
> >
> >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      9th Nov 2007
for each wbk in workbooks
if wbk.name = ThisWorkbook.name then
'do nothing
elseif lcase(wbk.name) = lcase("daily report.xls") then
'skip this, too
elseif lcase(left(wbk.name,4))= lcase("npp_") then
'skip more!
else
wbk.close savechanges:=false 'or true????
end if
next wbk

Greg H. wrote:
>
> How can i modify this to prevent thisworkbook.name and another excel file not
> to close? I need the files "Daily Reports.xls" and "NPP_*" to stay open.
> Thanks
>
> "Joel" wrote:
>
> > Easy
> >
> > for each wbk in workbooks
> > if wbk.name <> ThisWorkbook.name then
> > workbooks(wbk.name).close
> > end if
> > next wbk
> >
> > "anon" wrote:
> >
> > > HI,
> > >
> > > I'd like my wb on opening to close all other excel files that are open
> > > (prompting them to save first).
> > >
> > > I'd also like to prevent the user opening any other excel files whilst
> > > my wb is open.
> > >
> > > Is this possible (and is it a stupid thing to try and do?)
> > >
> > >


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      9th Nov 2007

Sub test()

For Each wbk In Workbooks
If wbk.Name <> ThisWorkbook.Name And _
wbk.Name <> "Daily Reports.xls" And _
Left(wbk.Name, 4) <> "NPP_" Then

Workbooks(wbk.Name).Close
End If
Next wbk

End Sub
"Greg H." wrote:

> How can i modify this to prevent thisworkbook.name and another excel file not
> to close? I need the files "Daily Reports.xls" and "NPP_*" to stay open.
> Thanks
>
> "Joel" wrote:
>
> > Easy
> >
> > for each wbk in workbooks
> > if wbk.name <> ThisWorkbook.name then
> > workbooks(wbk.name).close
> > end if
> > next wbk
> >
> > "anon" wrote:
> >
> > > HI,
> > >
> > > I'd like my wb on opening to close all other excel files that are open
> > > (prompting them to save first).
> > >
> > > I'd also like to prevent the user opening any other excel files whilst
> > > my wb is open.
> > >
> > > Is this possible (and is it a stupid thing to try and do?)
> > >
> > >

 
Reply With Quote
 
ellen lee
Guest
Posts: n/a
 
      11th Nov 2007
test
"Greg H." <(E-Mail Removed)> wrote in message
news:CB434118-83A6-4153-965C-(E-Mail Removed)...
> How can i modify this to prevent thisworkbook.name and another excel file
> not
> to close? I need the files "Daily Reports.xls" and "NPP_*" to stay open.
> Thanks
>
> "Joel" wrote:
>
>> Easy
>>
>> for each wbk in workbooks
>> if wbk.name <> ThisWorkbook.name then
>> workbooks(wbk.name).close
>> end if
>> next wbk
>>
>> "anon" wrote:
>>
>> > HI,
>> >
>> > I'd like my wb on opening to close all other excel files that are open
>> > (prompting them to save first).
>> >
>> > I'd also like to prevent the user opening any other excel files whilst
>> > my wb is open.
>> >
>> > Is this possible (and is it a stupid thing to try and do?)
>> >
>> >


 
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
How to open a list of excel files and get update, then close it? =?Utf-8?B?RXJpYw==?= Microsoft Excel Misc 4 10th Jun 2007 08:58 AM
open and close all excel files in directory =?Utf-8?B?QWxleA==?= Microsoft Excel Programming 2 24th Jan 2006 11:31 PM
Excel-Can't close 1 open Workbook without closing other open Workb =?Utf-8?B?ZnJhbWluZ2hhbQ==?= Microsoft Excel Misc 1 18th Oct 2004 08:59 PM
Re: How do I close some Excel files and leave others open without sav. JulieD Microsoft Excel Misc 0 14th Sep 2004 04:11 PM
Excel Closes all open excel files when I close one Ward Snyder Microsoft Excel Misc 0 7th Aug 2003 11:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.