PC Review


Reply
Thread Tools Rate Thread

Close almost all workbooks

 
 
ChrisP
Guest
Posts: n/a
 
      7th Aug 2008
I've written some VBA code to open one workbook (call it "A") and in the open
event for workbook A I have it coded to open various other workbooks ("B",
"C", "D", etc).

I'm doing it this way so all the links are updated (one is password
protected and I can't give out the password so I've had to code opening them
in VBA and lock the VBA code).

I have everything I need except how to close workbooks B, C, D, etc. I don't
want to close all the workbooks as users may have other excel workbooks open
at the time. Any help is appreciated!

Thanks,
Chris
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      7th Aug 2008
Hi Chris

Look at this:

Set wbB = Workbooks.Open(Filename:="Book1.xls") ' Open "B"
'Your code
'More code
wbB.Close ' Close "B"

Hopes it helps

Best regards,
Per
"ChrisP" <(E-Mail Removed)> skrev i meddelelsen
news:535435A2-EE7C-4667-8935-(E-Mail Removed)...
> I've written some VBA code to open one workbook (call it "A") and in the
> open
> event for workbook A I have it coded to open various other workbooks ("B",
> "C", "D", etc).
>
> I'm doing it this way so all the links are updated (one is password
> protected and I can't give out the password so I've had to code opening
> them
> in VBA and lock the VBA code).
>
> I have everything I need except how to close workbooks B, C, D, etc. I
> don't
> want to close all the workbooks as users may have other excel workbooks
> open
> at the time. Any help is appreciated!
>
> Thanks,
> Chris


 
Reply With Quote
 
ChrisP
Guest
Posts: n/a
 
      7th Aug 2008
Thanks! One more question, workbooks B & C I don't want to save but D I do.
How would I write that?

Thanks again!
Chris

"Per Jessen" wrote:

> Hi Chris
>
> Look at this:
>
> Set wbB = Workbooks.Open(Filename:="Book1.xls") ' Open "B"
> 'Your code
> 'More code
> wbB.Close ' Close "B"
>
> Hopes it helps
>
> Best regards,
> Per
> "ChrisP" <(E-Mail Removed)> skrev i meddelelsen
> news:535435A2-EE7C-4667-8935-(E-Mail Removed)...
> > I've written some VBA code to open one workbook (call it "A") and in the
> > open
> > event for workbook A I have it coded to open various other workbooks ("B",
> > "C", "D", etc).
> >
> > I'm doing it this way so all the links are updated (one is password
> > protected and I can't give out the password so I've had to code opening
> > them
> > in VBA and lock the VBA code).
> >
> > I have everything I need except how to close workbooks B, C, D, etc. I
> > don't
> > want to close all the workbooks as users may have other excel workbooks
> > open
> > at the time. Any help is appreciated!
> >
> > Thanks,
> > Chris

>
>

 
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
Workbooks.Close andim Microsoft Excel Programming 5 20th Jun 2008 06:18 PM
workbooks close before OlieH Microsoft Excel Programming 1 6th Apr 2008 08:40 AM
How to close All Workbooks Mervyn Thomas Microsoft Excel Programming 1 28th Dec 2007 09:22 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
close all other workbooks =?Utf-8?B?Um9i?= Microsoft Excel Programming 5 5th Feb 2006 08:44 PM


Features
 

Advertising
 

Newsgroups
 


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