PC Review


Reply
Thread Tools Rate Thread

closing workbooks

 
 
=?Utf-8?B?RXJpYw==?=
Guest
Posts: n/a
 
      19th Sep 2007
Hello All,

Is there a macro to close a workbook after you have imported the information
from that book? This workbooks name will change on a daily basis. I don't
want to close the workbook that has just had the information imputed into it.

ie: book 1 is always open. I want to imput info from book 2. I have
opened book 2 and now want to close it as soon as the macro is completed
imputing the information into book 1 and so on. I still want book 1 open so
I can continue imputing new information from other books. Thank you
inadvance for your help
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?=
Guest
Posts: n/a
 
      19th Sep 2007
Workbooks("Book2.xls").Close False

Does that work?
--
Charles Chickering

"A good example is twice the value of good advice."


"Eric" wrote:

> Hello All,
>
> Is there a macro to close a workbook after you have imported the information
> from that book? This workbooks name will change on a daily basis. I don't
> want to close the workbook that has just had the information imputed into it.
>
> ie: book 1 is always open. I want to imput info from book 2. I have
> opened book 2 and now want to close it as soon as the macro is completed
> imputing the information into book 1 and so on. I still want book 1 open so
> I can continue imputing new information from other books. Thank you
> inadvance for your help

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      19th Sep 2007
If you macro opens the workbook, then you should be able to retain a
reference to it and close it. If you open it yourself manually and just want
the macro to close it and the macro is in Book1 (an there are only Book1 and
Book2 open ) then

Dim bk as Workbook
for each bk in workbooks
if bk.windows(1).Visible then
if bk.Name <> thisworkbook.Name then
bk.Close SaveChanges:=False
exit for
end if
end if
Next

--
regards,
Tom Ogilvy

"Eric" wrote:

> Hello All,
>
> Is there a macro to close a workbook after you have imported the information
> from that book? This workbooks name will change on a daily basis. I don't
> want to close the workbook that has just had the information imputed into it.
>
> ie: book 1 is always open. I want to imput info from book 2. I have
> opened book 2 and now want to close it as soon as the macro is completed
> imputing the information into book 1 and so on. I still want book 1 open so
> I can continue imputing new information from other books. Thank you
> inadvance for your help

 
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
Closing workbooks w/o closing Excel Barb in MD Microsoft Excel Misc 4 15th Feb 2010 06:44 PM
Multiple workbooks open -- closing workbooks =?Utf-8?B?SmFuZXQgUGFuaWdoZXR0aQ==?= Microsoft Excel Discussion 3 13th Nov 2007 05:43 PM
Closing Workbooks =?Utf-8?B?Ym9kaGlzYXR2YW9mYm9vZ2ll?= Microsoft Excel Programming 4 20th Jun 2006 01:57 PM
Closing excel application without closing all workbooks at the sa. =?Utf-8?B?S2l3aSBSb3hpZQ==?= Microsoft Excel Setup 2 30th Oct 2004 02:18 AM
Closing down workbooks DonB Microsoft Excel Misc 1 11th Aug 2004 09:11 AM


Features
 

Advertising
 

Newsgroups
 


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