Microsoft KB Archive/102336

From BetaArchive Wiki

Microsoft Knowledge Base

Excel: Can't Open Template with NEW() in Auto-Open Macro

Last reviewed: September 12, 1996
Article ID: Q102336

The information in this article applies to:

  • Microsoft Excel for Windows, versions 4.0, 4.0a
  • Microsoft Excel for the Macintosh, versions 2.2, 3.0, 4.0

SYMPTOMS

When you use the NEW() function in an auto-open macro that runs at startup, if you use a saved template name (that is, worksheet, sheet) the macro will halt and will not open a template.

Also, note that page 285 of the "Function Reference" states that you can use quoted text to open a nondefault template. This information is not correct if you use the NEW() function in an auto-open macro. If you use a text string enclosed in quotation marks for the type_num argument in the NEW() function in an auto-open macro, the macro will halt and will not open a template.

CAUSE

This behavior occurs because the auto-new macro is loaded before the list of template names is loaded in memory, and therefore, the template is unavailable at the time that the NEW() function is run.

WORKAROUND

To work around this problem, use the OPEN() function instead of the NEW() function to open a worksheet based on the saved template.

MORE INFORMATION

You can use NEW() with a type_num argument of 1 through 5 to successfully open the standard (default) templates in Microsoft Excel.

Steps to Reproduce Situation

To duplicate the behavior described above:

  1. In a new macro sheet, type the following macro:

           A1: Auto_Open
           A2: =NEW("sheet")
           A3: =RETURN()
  2. From the Formula menu, choose Define Name. In the Name box, type "Auto_Open" (without the quotation marks). In the Refers To box, type "=$A$1" (without the quotation marks).
  3. Under Macro, select the Command option.
  4. Save the macro in the XLSTART subdirectory (this should be located in the same directory where you installed Microsoft Excel).
  5. Close Microsoft Excel
  6. Restart Microsoft Excel

Using the formula =OPEN("C:\EXCEL40\XLSTART\SHEET.XLT") will produce a worksheet from the saved template, SHEET.XLT, which should be located in the EXCEL\XLSTART subdirectory.

REFERENCES

"Function Reference", version 4.0, page 285


KBCategory: kbdocerr

KBSubcategory:

Additional reference words: 4.00 4.00a




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: September 12, 1996
©1997 Microsoft Corporation. All rights reserved. Legal Notices.