drew.j.harrison
Board Regular
- Joined
- Jul 9, 2010
- Messages
- 65
[Note: I made a mistake in the title of this thread it should say workbook not worksheet]
So I have a user form called "User_Controls" and another macro that opens and locates it. When I try to call this in the Sub Workbook_Open it force closes excel. The weird thing is it only does it if I have already enabled macros for the workbook. When I change the workbook name so it prompts me to enable macros again and click "enable content" it works just fine. Any idea what could be going on here and how I could fix it? BTW I have also tried using Sub Workbook_Activate as well to launch the user form and got the same result. My code is below. Thanks for the help.
FYI I also posted this question on the excelforum forums here:
Userform won't open with worksheet. Causing error and force close.
So I have a user form called "User_Controls" and another macro that opens and locates it. When I try to call this in the Sub Workbook_Open it force closes excel. The weird thing is it only does it if I have already enabled macros for the workbook. When I change the workbook name so it prompts me to enable macros again and click "enable content" it works just fine. Any idea what could be going on here and how I could fix it? BTW I have also tried using Sub Workbook_Activate as well to launch the user form and got the same result. My code is below. Thanks for the help.
Code:
Private Sub Workbook_Open()
Call Open_And_Locate_Userform(User_Controls)
End Sub
Code:
Sub Open_And_Locate_Userform(UF)
Application.ScreenUpdating = False
With UF
.Show
.StartUpPosition = 0
.Top = Application.Top + Application.Height - UF.Height - 33
.Left = Application.Left + Application.Width - UF.Width - 17
End With
AppActivate "Microsoft Excel"
Application.ScreenUpdating = True
End Sub
FYI I also posted this question on the excelforum forums here:
Userform won't open with worksheet. Causing error and force close.
Last edited: