Why does workbook 1 stay open after Workbook 2 opens?

BillLogue

New Member
Joined
Nov 6, 2011
Messages
5
I have a macro that closes workbook one and opens workbook two. These are in user forms. It works fine except that workbook two automatically opens a user form and workbook one wont finish closing until a the user form is deactivated. I do not want this. Users will not have the ability to exit the form when this is ready to publish. Here is the codes and I hope you can help.

From workbook 1 to workbook 2
'Opens Workbook 2
Workbooks.Open Filename:=ThisWorkbook.Path & "\workbook2.xls"
'Close Workbook selection
Unload Me
'Closes Workbook 1 WITHOUT Saving
ThisWorkbook.Close False

Workbook 2 open

Private Sub Workbook_Open()
'Always Open on Sheet1.
Worksheets("Sheet1").Activate
Range("A1").Select
'Open the Roster Welcome User Form.
Userform3.Show
End Sub


Thank you in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Bill

Welcome to the MrExcel board!

You originally posted this in the 'Questions in Other Languages' forum. Since your question is in English, it should not have been there and so I have moved it.

Also, the 'Questions in Other Languages' forum doesn't get as much traffic as this one so you were less likely to get an answer there anyway.

Your question is not in an area that I am strong at but hopefully somebody else will step in soon with a suggestion or two (though weekends are usually also a bit slower).
 
Upvote 0
Thank you for moving me to the correct area. I'm currently stationed in Japan so it probably has to do with my time zone. Once again, thank you.
 
Upvote 0
Did you try unloading the form AFTER closing the workbook ?

Code:
From workbook 1 to workbook 2
'Opens Workbook 2
Workbooks.Open Filename:=ThisWorkbook.Path & "\workbook2.xls"
'Close Workbook selection
'Closes Workbook 1 WITHOUT Saving
[COLOR=Red]ThisWorkbook.Close False
[/COLOR][COLOR=Red]Unload Me[/COLOR]
 
Upvote 0
When you open a modal form, code execution suspends. Can you open the form modeless?

In workbook 1,
Code:
    '...
    Workbooks.Open Filename:=ThisWorkbook.Path & "\workbook2.xls"
    Unload Me
    ThisWorkbook.Close False
    ...
End Sub
In workbook 2,
Code:
Private Sub Workbook_Open()
    Worksheets("Sheet1").Activate
    Range("A1").Select
    Userform3.Show [COLOR=red]vbModeless[/COLOR]
End Sub
 
Upvote 0
Thank you both for the replies. I will try them as soon as possible and post once I find out if they work. Thank you again.
 
Upvote 0
Thank you SHG. This worked perfectly. Can't believe that I missed it. Great call.

When you open a modal form, code execution suspends. Can you open the form modeless?

In workbook 1,
Code:
    '...
    Workbooks.Open Filename:=ThisWorkbook.Path & "\workbook2.xls"
    Unload Me
    ThisWorkbook.Close False
    ...
End Sub
In workbook 2,
Code:
Private Sub Workbook_Open()
    Worksheets("Sheet1").Activate
    Range("A1").Select
    Userform3.Show [COLOR=red]vbModeless[/COLOR]
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top