Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Working with Two WorkBooks

HI,

I'm a bit mixed up with running macros from other Workbooks.

There are two workbooks open, say Book1 and Book2.
At the end of a session, with Book2 being the active workbook, I want to run
a macro (called, say ShutDown ) in Book1 which will then close Book2. I'm Ok
after that.

If it helps - Book1 is Workbooks(1) and Book2 is Workbooks(2)

Any pointers please ?

regards,
Don
--



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Working with Two WorkBooks

Donald,

I am assuming that the call to Shutdown is from a macro in Book2. If so, add
this to your macro in Book2

Application.Run ("Book1!Shutdown")

The shutdown macro would include this line of code

Workbooks("Book2").Close

If you want it to close without saving, precede by

Workbooks("Book2").Saved = True

If you want it to save Book2 without prompting you, precede by

Application.DisplayAlerts = False

and set to True afterwards.

Hop I haven't mixed up Book1 and Book2.

--

HTH

Bob Phillips

"Donald Lloyd" wrote in message
...
HI,

I'm a bit mixed up with running macros from other Workbooks.

There are two workbooks open, say Book1 and Book2.
At the end of a session, with Book2 being the active workbook, I want to

run
a macro (called, say ShutDown ) in Book1 which will then close Book2. I'm

Ok
after that.

If it helps - Book1 is Workbooks(1) and Book2 is Workbooks(2)

Any pointers please ?

regards,
Don
--





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Working with Two WorkBooks

Nothing mixed up, Bob

That's great. Thank you,

Don

--

"Bob Phillips" wrote in message
...
Donald,

I am assuming that the call to Shutdown is from a macro in Book2. If so,

add
this to your macro in Book2

Application.Run ("Book1!Shutdown")

The shutdown macro would include this line of code

Workbooks("Book2").Close

If you want it to close without saving, precede by

Workbooks("Book2").Saved = True

If you want it to save Book2 without prompting you, precede by

Application.DisplayAlerts = False

and set to True afterwards.

Hop I haven't mixed up Book1 and Book2.

--

HTH

Bob Phillips

"Donald Lloyd" wrote in message
...
HI,

I'm a bit mixed up with running macros from other Workbooks.

There are two workbooks open, say Book1 and Book2.
At the end of a session, with Book2 being the active workbook, I want to

run
a macro (called, say ShutDown ) in Book1 which will then close Book2.

I'm
Ok
after that.

If it helps - Book1 is Workbooks(1) and Book2 is Workbooks(2)

Any pointers please ?

regards,
Don
--







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Working with Two WorkBooks

Just a further small query -
Application.Run("Book1!Shutdown")
What would the format be if referring to Book1 by its Index ?

regards,
Don

--

"Bob Phillips" wrote in message
...
Donald,

I am assuming that the call to Shutdown is from a macro in Book2. If so,

add
this to your macro in Book2

Application.Run ("Book1!Shutdown")

The shutdown macro would include this line of code

Workbooks("Book2").Close

If you want it to close without saving, precede by

Workbooks("Book2").Saved = True

If you want it to save Book2 without prompting you, precede by

Application.DisplayAlerts = False

and set to True afterwards.

Hop I haven't mixed up Book1 and Book2.

--

HTH

Bob Phillips

"Donald Lloyd" wrote in message
...
HI,

I'm a bit mixed up with running macros from other Workbooks.

There are two workbooks open, say Book1 and Book2.
At the end of a session, with Book2 being the active workbook, I want to

run
a macro (called, say ShutDown ) in Book1 which will then close Book2.

I'm
Ok
after that.

If it helps - Book1 is Workbooks(1) and Book2 is Workbooks(2)

Any pointers please ?

regards,
Don
--







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
Merging WorkBooks Not Working Gina Excel Discussion (Misc queries) 1 August 19th 08 11:30 PM
working with excel 97 workbooks RDG Excel Discussion (Misc queries) 5 August 5th 08 07:29 PM
Working on Multiple Workbooks create_share Excel Discussion (Misc queries) 1 July 24th 06 12:25 PM
Working with Different workbooks eawinga Excel Discussion (Misc queries) 2 March 7th 05 02:06 PM
Working with Different workbooks eawinga Excel Discussion (Misc queries) 0 March 7th 05 09:59 AM


All times are GMT +1. The time now is 09:03 PM.

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"