Microsoft KB Archive/123576

{|
 * width="100%"|

XL5: DocErr Add Method of Workbooks Class

 * }

-

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")