Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

closing workbooks

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 19 Sep 2007 13:44 GMT
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
Charles Chickering - 19 Sep 2007 13:46 GMT
Workbooks("Book2.xls").Close False

Does that work?
Signature

Charles Chickering

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

> Hello All,
>
[quoted text clipped - 7 lines]
> I can continue imputing new information from other books.  Thank you
> inadvance for your help
Tom Ogilvy - 19 Sep 2007 13:56 GMT
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

Signature

regards,
Tom Ogilvy

> Hello All,
>
[quoted text clipped - 7 lines]
> I can continue imputing new information from other books.  Thank you
> inadvance for your help
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.