PDA

View Full Version : Solved: Auto Load Form when Excel Launches



Nosstech
08-12-2008, 08:18 AM
How do I automatically run a form when Excel loads?

mailman
08-12-2008, 08:25 AM
Private Sub Workbook_Open()
YourForm.Show
End Sub

Nosstech
08-12-2008, 09:22 AM
Private Sub Workbook_Open()
YourForm.Show
End Sub

When I put that into my workbook, nothing happens.

Is this code supposed to open the form when the workbook is opened?

Bob Phillips
08-12-2008, 09:26 AM
You have to put that code in the ThisWorkbook code module.

mailman
08-12-2008, 11:37 AM
When I put that into my workbook, nothing happens.

Is this code supposed to open the form when the workbook is opened?


As xld outlined, you'll need to add it to the Code Behind page for the specific worksheet you'll launch your form from. To do this, one way is to right click the worksheet and select: View Code

Put the code in there, and change the YourForm portion of the code, to the name of the form you want to launch.

Bob Phillips
08-12-2008, 02:21 PM
No, I said ThisWorkbook, not the worksheet. Workbook_Open will do nothing if put in a worksheet code module. To get there use

right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code

Nosstech
08-13-2008, 07:57 AM
No, I said ThisWorkbook, not the worksheet. Workbook_Open will do nothing if put in a worksheet code module. To get there use

right click on the Excel icon on the worksheet
(or next to the File menu if you maximise your workbooks),
select View Code from the menu, and paste the code
Thanks xld. That kind of works. When I open the workbook, the form loads, but then it also opens the debugger. This is my code for "This Workbook":

Private Sub Workbook_Open()
frmMainMenu.Show
End Sub

mailman
08-13-2008, 08:17 AM
Hey Nosstech. It worked for me. The form is off centre, but it worked.

See attached.

9712

Apologies for my blunder above.

Nosstech
08-13-2008, 08:35 AM
Hey Nosstech. It worked for me. The form is off centre, but it worked.

See attached.

9712

Apologies for my blunder above.

Mailman, Thanks. I am still having the same issue. It must be something locally with excel/my machine.

Thanks again