Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default closing workbooks

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default closing workbooks

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default closing workbooks

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
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
Closing Workbooks bodhisatvaofboogie Excel Programming 4 June 20th 06 01:57 PM
Closing Other Workbooks Tim Mayes[_2_] Excel Programming 4 December 13th 04 11:08 PM
Closing workbooks Mischa Browne Excel Programming 4 June 17th 04 04:16 PM
Opening and Closing workbooks Jase Excel Programming 1 October 15th 03 06:28 AM


All times are GMT +1. The time now is 01:46 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"