Auto_Open Procedures

An Auto_Open procedure runs when the user opens the workbook that contains the procedure. You can use an Auto_Open procedure to set up menu bars under program control, to customize the workbook for the operating system it's running with, to display a custom startup screen, or to initiate links to other files or other applications.

For example, the following procedure automatically adds a custom menu item to the worksheet Tools menu.


Sub Auto_Open()
    MenuBars(xlWorksheet).Menus("Tools").MenuItems.Add _
        caption := "My Analysis", _
        onAction := ThisWorkbook.Name & "!Module2.MyAnalysisProc", _
        before := 1
End Sub