Referencing one workbook in other???

  • Thread starter Thread starter Haldun Alay
  • Start date Start date
H

Haldun Alay

Hi,

I have one workbook (book1) which is referenced in another one (book2).
book1 is database workbook, book2 is reporting book and each workbook has
some vba codes. i wrote some codes to open book1 when book2 is opened. also
some codes for closing routines exist.

The problem is when i try to close book2, book1 has to closed otomatically.
but excel gives me some error messages that says -book1 is referenced in
other workbooks, closing not possible-. and leaves book1 opened.

does anybody have an idea, how can i walk around that problem.



Thanks.


Haldun
 
If you open book2, then book1 will be opened automatically - you don't need
code to open it.

You must close book2 before you can close book1. If your code to close
book1 is in Book2, then you will not be able to do that since book2 will
remain open while it is running the code.

What you might want to do is have code in Book1 that will close book1.
Then, in the Book2 beforeClose event, use application.Ontime command to
execute the code in Book1. You can see examples of using application ontime
at Chip Pearson's site

http://www.cpearson.com/excel/ontime.htm

Although his example demonstrates repetitive calls to ontime - you only need
to call it once.
 
Back
Top