Question : Userform modeless - modal

I have 2 workbooks, Main.xls & Secondary.xls.  When Main.xls is opened, a modal userform appears which allows the user to do several things including opening the Secondary.xls workbook.  When the button to open Secondary.xls is selected, the userform is hidden.  In Secondary.xls the user can depress a customized menu button to return to Main.xls which also makes Secondary.xls visible=False and shows the userform in Main.xls again.  I had to show the userform in modeless form now to eliminate the procedure from waiting for the user to act on the userform because one of the buttons on the userform is to close both of these workbooks.  The procedure would terminate before executing all code when in modal form.  The problem is I want the userform to be modal in the end so user cant interact with standard Excel menu items, etc.  What and when would be the best way to switch the userform from modeless to modal when going from one workbook to the other like in this case?

Answer : Userform modeless - modal

Does your routine in Secondary specifically activate the Main workbook when it hides the secondary one? (If not, I don't see what routine would be waiting for a response when the Main workbook's Activate event fires)
You may want to consider using a class module in Main with a workbook variable declared WithEvents. That way you can trap the deactivate or close event of Secondary from Main and reshow the userform with the only running routine being in Main.
Alternatively you could fudge it using Application.OnTime to reshow the form.
Regards,
Rory
Random Solutions  
 
programming4us programming4us