23cp
12-23-2008, 02:22 AM
Hi. I need help on the following problem. I use Excel 2007.
I have two workbooks (Book1 and Book2). When Book1 opens, its Workbook Open procedure displays a Userform1 that has a Command Button. The Button opens Book2. Book2 has a Workbook Open procedure that should close Book1 and display a new Userform2. UserForm2 resides in Book2 and is called from the Workbook_Open procedure of Book2, just after the closing of Book1. When the Workbook Open procedure of Book2 closes Book1, the procedure stops there and does not show the UserForm2. How can I get the Workbook Open procedure of Book2 to execute both steps of closing Book1 and showing Userform2? This must be done by clicking the Button on Userform1.
To add to my confusion... if I manually open both workbooks Book1 and Book2 and, subsequently, open the VBE code screen and call for the module ThisWorkbook of Book2's codes, and if I position the cursor in the codes of the Workbook_Open procedure and execute the procedure (F5), the Book1 is correctly closed and the Userform2 is correctly shown. Why does the procedure execute completely when I call it manually, but does stop short of showing the Userform2 when it is called automatically by the procedure in Book1? Note that, when done manually, it does not matter if I am doing this when Book1 or Book2 is activated.
If you have any help on this I would greatly appreciate. Thanks. Claude.
I have two workbooks (Book1 and Book2). When Book1 opens, its Workbook Open procedure displays a Userform1 that has a Command Button. The Button opens Book2. Book2 has a Workbook Open procedure that should close Book1 and display a new Userform2. UserForm2 resides in Book2 and is called from the Workbook_Open procedure of Book2, just after the closing of Book1. When the Workbook Open procedure of Book2 closes Book1, the procedure stops there and does not show the UserForm2. How can I get the Workbook Open procedure of Book2 to execute both steps of closing Book1 and showing Userform2? This must be done by clicking the Button on Userform1.
To add to my confusion... if I manually open both workbooks Book1 and Book2 and, subsequently, open the VBE code screen and call for the module ThisWorkbook of Book2's codes, and if I position the cursor in the codes of the Workbook_Open procedure and execute the procedure (F5), the Book1 is correctly closed and the Userform2 is correctly shown. Why does the procedure execute completely when I call it manually, but does stop short of showing the Userform2 when it is called automatically by the procedure in Book1? Note that, when done manually, it does not matter if I am doing this when Book1 or Book2 is activated.
If you have any help on this I would greatly appreciate. Thanks. Claude.