XL5: DocErr Add Method of Workbooks Class

ID: Q123576


The information in this article applies to:


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) 

Additional query words: 5.00a 5.00c


Keywords          : xlwin 
Version           : 5.00
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: May 2, 1999