XL5: DocErr Add Method of Workbooks Class

Last reviewed: September 12, 1996
Article ID: Q123576
The information in this article applies to:
  • Microsoft Excel for Windows, version 5.0

SYMPTOMS

In Microsoft Excel 5.0, Visual Basic Help states the following about the Template argument for the Add method of the Workbooks collection:

   Can be a string specifying a template for the new workbook (the
   string can include a file path), or a constant to create a new
   workbook containing a single sheet (one of xlWorksheet, xlChart,
   xlExcel4MacroSheet, or xlExcel4IntlMacroSheet).

This information is incorrect. The correct text is the following:

   A constant (one of xlWorksheet, xlChart, xlExcel4MacroSheet, or
   xlExcel4IntlMacroSheet) that specifies a new workbook is created
   containing a single sheet of this type.

STATUS

Microsoft has confirmed this to be a problem in Visual Basic Help in Microsoft Excel version 5.0. This information has been corrected in Visual Basic Help that is included with Microsoft Excel version 5.0c.

MORE INFORMATION

The Add method for Workbooks class is equivalent to Choosing New from the File menu and choosing either a custom template or the built-in workbook template. For a custom workbook template to be available in the New dialog box, it must either be in the XLSTART directory or the alternate startup directory. The Alternate startup directory can be set by choosing the General Tab after choosing Options from the Tools menu and typing a path for Alternate Startup File Location. Therefore, adding any other path for the template will not work. If you try to use a different path, you receive the following error message

   Run-time error 1004:  Add method of workbooks class failed

If a template from another directory needs to be used, use Workbooks.Open instead. For example, you could use the following command:

   Workbooks.Open("C:\MYDIR\MYTEMP.XLT")

REFERENCES

Microsoft Excel 5.0 Visual Basic Help "Excel 5 Visual Basic for Applications Reference," Microsoft Press, page 38 "User's Guide," version 5.0, Chapters 35-36

To find the Add method in Help, choose the search button in Visual Basic Help and type:

   Add Method (Workbooks Collection)


KBCategory: kbusage kbdocerr
KBSubcategory: xlwin

Additional reference words: 5.00 5.00a 5.00c



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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.