Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing a VB Form on opening an Excel Workbook

Status
Not open for further replies.

Crashtestdummy

Materials
May 8, 2002
10
I am able to execute a for from withing an excell workbook, but throught the aid of an "main Menu" type button. I am looking to execute my form as the particular excel file is opened. Anyone have any Idea's?

 
Replies continue below

Recommended for you

There is a pre-defined sub called Workbook_Open(). Use the tools menu to display the Visual Basic editor (ALT+F11 in Excel 97). In the Project Browser window (usually found at top left of screen), double-click the "ThisWorkbook" object to display the code window for the workbook itself. The code window will now show two drop downs at the top. Change the left drop-down to say "Workbook" (shows "General" as default). This will automatically create the stub for the Workbook_Open() procedure. Within this procedure stub, type in "Load frmMyForm" (without the quotes) and substitute the frmMyForm name with the name of your form.

When the workbook is opened (provided the user chooses NOT to disable macros), your form will be displayed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor