Auto_Open Macro Not Working Correctly on Excel Worksheet

Last reviewed: August 20, 1995
Article ID: Q28189
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.x, 4.x, 5.0, 5.0c
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, version 7.0

SUMMARY

To create a macro that runs automatically every time you open a particular Excel document, do the following:

Microsoft Excel version 5.0 and later

  1. Open the workbook from which you want to run your macro. Select either a worksheet or macro sheet tab.

  2. On the sheet, define the name Auto_Open that refers to the macro that you want to run, as in the following examples:

          =My_Macro (My_Macro located in same workbook)
    

          -or-
    

          =BOOK2.XLS!My_Macro (My_Macro located in separate workbook)
    

    Note that My_Macro may be either a Visual Basic macro or a Microsoft Excel 4.0 macro.

  3. Close and save the workbook.

Microsoft Excel versions 2.x, 3.0, 4.0

  1. Open both your worksheet and your macro sheet.

  2. On your worksheet, define your Auto_Open macro with a reference to the open macro sheet, as in the following example:

          =test.xlm!my_macro
    

  3. Close the macro sheet.

  4. Save the worksheet.

The Auto_Open macro now runs correctly when you open the worksheet.

MORE INFORMATION

In Excel 2.x for Windows, symptoms of an improperly defined Auto_open macro are:

  • dropping to MS-DOS
  • the error message "Cannot find Auto_open"
  • system lockups upon loading the document

REFERENCES

"Microsoft Excel User's Guide," version 3.0, pages 622-624

"Microsoft Excel Functions and Macros," version 2.x, page 194


KBCategory: kbusage
KBSubcategory:

Additional reference words: 7.00 2.00 2.0 2.01 2.1 2.10 2.2 2.21 2.20 3.00
3.0 4.00 4.0 5.00 5.0 auto open


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 20, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.