![]() |
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 -- |
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 -- |
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 -- |
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 -- |
All times are GMT +1. The time now is 11:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com