PDA

View Full Version : Close Workbook and Show Userform



pcsparky
01-21-2009, 11:49 AM
I'm new to this and have been hitting my head against a brick wall. :banghead:

I have set up Workbook1 Userform3 to open a specific file (Workbook2).

In Sheet1 of Workbook2 is a button that I am trying to get to Save and Close Wb2 and show Wb1 Userform3 again so that the user can select another file to open.

The problem I seem to have is that if I run code to Close Wb2 and then show Userform3 then the latter code doesn't run because the program isn't running anymore.

If I show the form first and then try to execute the Close command the program runs with Userform3 and won't execute the Close command until the form unloads.

I've tried to close Wb2 by placing it's name in a cell on a Wb1 sheet and executing the Close command using this data but although the Userform tries to open (with a blank background) it then disappears.

What is the best way to achieve what I'm after, closing a workbook and getting the Userform3 to show again.

Bob Phillips
01-21-2009, 12:45 PM
Do it the other way around.

Have a procedure in workbook 1 that closes workbook2 and then shows the form.

If it has to be initiated from workbook 2, run this procedure from workbook 2 using Application.Run.

pcsparky
01-22-2009, 08:33 AM
Thankyou, got it working now.

lucas
01-22-2009, 10:38 AM
Be sure to mark your thread solved using the thread tools at the top of the page.