Microsoft KB Archive/28189

= Auto_Open Macro Not Working Correctly on Excel Worksheet =

Article ID: 28189

Article Last Modified on 11/16/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0c
 * Microsoft Excel 4.0c
 * Microsoft Excel 3.0a
 * Microsoft Excel 2.10d
 * Microsoft Excel 2.1 Standard Edition
 * Microsoft Excel 2.01
 * Microsoft Excel 2.0 Standard Edition
 * Microsoft Excel 5.0 Standard Edition

-



This article was previously published under Q28189



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
 Open the workbook from which you want to run your macro. Select either a worksheet or macro sheet tab. 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. Close and save the workbook.

Microsoft Excel versions 2.x, 3.0, 4.0
 Open both your worksheet and your macro sheet. 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

 Close the macro sheet.</li> Save the worksheet.</li></ol>

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

<div class="moreinformation_section">

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


 * dropping to MS-DOS
 * the error message &quot;Cannot find Auto_open&quot;
 * system lockups upon loading the document

<div class="references_section">